|
Posted by Boris Stumm on 10/09/07 10:13
Alec wrote:
> $result = @mysql_query ("SELECT company, priority FROM table1 WHERE
> priority ='high' "); UNION; @mysql_query ("SELECT company, priority
> FROM table1 WHERE priority ='low' ");
First thing to remember: post readable code.
$result = @mysql_query("SELECT company, priority FROM table1
WHERE priority ='high' ");
UNION;
@mysql_query ("SELECT company, priority FROM table1
WHERE priority ='low' ");
Now it is quite visible what is happening. You only assign the
first query to $result.
Solution if the only priorities that exist are "high" and "low":
SELECT company, priority FROM table1;
Other solution:
SELECT company, priority FROM table 1
WHERE priority in ('high', 'low');
The less-than-optimal, but correct UNION-solution:
SELECT company, priority FROM table 1
WHERE priority ='high')
UNION
SELECT company, priority FROM table 1
WHERE priority = 'low');
You REALLY should read some SQL-Tutorial, because this is
really BASIC knowledge about SQL.
Navigation:
[Reply to this message]
|