If you took junior high school math, you should have.
For example, what is the value of
Code:
3 + 4 * 2
??
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
Code:
3 + ( 4 * 2 )
for an answer of 11.
If you WANTED the answer of 14, you should have written
Code:
( 3 + 4 ) * 2
***********
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.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
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 |.
Wow i never knew that either, i knew about the math operators, (i could google it but lets see if i remember) order is division, multiplication, addition, subtraction i think. lol now i will google see if im wrong lol..
That blows my mind a bit about the logical operators.
That is just one of many reasons folks the really good coders charge a good price for their work, they earn it, they deserve it, and they need all that cash to stuff in their ears to keep this kind of stuff from leaking out lol..