I got issue while i execute my sql query with paymentmethod 1 show it's show paymentmethod 3 also. Please Check where i am wrong. Thanks in advance

This is my sql query:-
SELECT (SELECT COUNT(u.`upperuserid`)
FROM user u
WHERE u.upperuserid = user.usernewid
) as ref,
usernewid,
user.paymentmethod,usersecond, mod_date
from user
HAVING ref < 2 or user.usersecond=0 and paymentmethod = 1
ref < 2 or user.usersecond=0 and paymentmethod = 1
Operator precedence. This is being interpreted as:
(ref < 2) or (user.usersecond=0 and paymentmethod = 1)
Since the records in question match ref < 2, they are returned.
Explicitly define the precedence of your logic by grouping expressions in parentheses:
(ref < 2 or user.usersecond=0) and (paymentmethod = 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With