requirements, I want to retrieve the results of a =1 or b=1 and c = 0 or c=1
Example:
SELECT * FROM Test where a = 1 or b = 1 and (c = 0 or c = 1)
This retrieves the result set of A=1 or b=1, and then filters out the results of c=0 or c=1.
If we change the wording of the
SELECT * FROM Test where a = 1 or b = 1 and c = 0 or c = 1
This retrieves the result set of a=1 or B =1 or c=1, and then filters out the results of the c=0, which is not what I expected, so it is OK to adjust their processing order in parentheses.
First filter the same hospital or the same department of the user list, and then according to the number of medical said and the number of fans again filter the user list,
Correct sql:
SELECT a.* from Xm_user a WHERE (a.user_hospital = ' 301 Hospital ' or a.user_department = ' orthopedic ') and a.user_id! = 1
And not EXISTS (SELECT b.* from xm_user_friendship b WHERE b.fs_from_user_id = 1 and b.fs_to_user_id = a.user_id);
Error SQL:
SELECT a.* from Xm_user a WHERE a.user_hospital = ' 301 Hospital ' or a.user_department = ' orthopedic ' and a.user_id! = 1
And not EXISTS (SELECT b.* from xm_user_friendship b WHERE b.fs_from_user_id = 1 and b.fs_to_user_id = a.user_id);
MySQL SQL statements handle the order of operations for OR and and in parentheses