11-01-2009, 09:21 PM
|
#4 (permalink)
|
|
The Wanderer
Join Date: Aug 2009
Posts: 17
Thanks: 0
|
I don't know if I fully understand what you are asking without knowing more details but why can't you just select the five columns and use a UNION for the different WHERE conditions.
Kinda like:
Code:
(SELECT col1, col2, col3, col4, col5
FROM table
WHERE col1 = 'whatever')
UNION
(SELECT col1, col2, col3, col4, col5
FROM table
WHERE col2 = 'whatever')
UNION
(SELECT col1, col2, col3, col4, col5
FROM table
WHERE col3 = 'whatever');
Similar to how you described doing it in PHP however it may have better performance because it is just commissioning one query to mysql instead of the 3 and it may be faster in joining the results together also I don't know.
If I am completely wrong then by all means just ignore me :)
|
|
|
|