PDA

View Full Version : AND and an OR in mysql Query


casbboy
8-7-04, 06:49 PM
I have the following Query



mysql_query("SELECT * FROM headline WHERE field=9 OR field=8 AND issue=$issue ORDER BY newsid DESC LIMIT $min,$max",$connection);



The query still grabs rows even if the issue does not equal the $issue variable. How can I fix this?

Thanks
Ryan

Pig
8-7-04, 07:08 PM
mysql_query("
SELECT
*
FROM
headline
WHERE
issue=$issue AND
(
field=9 OR
field=8
)
ORDER BY
newsid DESC
LIMIT
$min,
$max
",$connection);

casbboy
8-8-04, 03:00 AM
Thanks, will give it a try.

Ryan