Have you heard of PRECEDENCE of operators?
If you took junior high school math, you should have.
For example, what is the value of
??
If you said 14, then back to school for you!
Multiplication has a higher precedence than addition, so that expression is evaluate as if you had coded
for an answer of 11.
If you WANTED the answer of 14, you should have written
***********
Guess what? SAME THING applies to LOGICAL operators. Yes, in SQL. And in PHP and in JavaScript and in every other standard computer language.
AND has a higher precedence than OR.
&& has a higher precedence than ||.
& has a higher precedence then |.
So... What you need is:
Code:
$sql = "
SELECT * FROM hits
WHERE vc=1 AND country = 'us'
AND ( ua LIKE '%bot%' || ua LIKE '%spider%' || state NOT LIKE 'Florida')
";
mysql_query( $sql )
Incidentally: Personally, I would use AND and OR in SQL, because ANSI SQL doesn't support && and || even if MySQL does. Be prepared for the day you may use some other DB than MySQL.