There are no operator limits, but they directly affect the performance of the query, including the order in which they are placed.
Your query is valid, but may not bring you the desired result by the order of the operators. The AND
will always be processed before the OR
, so the results returned by the query, has the name equal to 'Fulano' or the email equal to the informed and id different from 1.
To correct this problem, use parentheses to inform which will be processed first, this way:
$sql = "SELECT * FROM usuarios WHERE (nome = 'Fulano' OR email = '[email protected]') AND id <> 1";
If your field id
is numeric, it is not required that it is in quotes ('1') the database will have to perform text to number conversion unnecessarily.
Still on the operators, in mathematical logic the operator AND corresponds to multiplication, and the OR to addition. Therefore of the order, only mathematics.