Nura111
asked on
Using OR and AND in mysql query
HI how Can I change the syntax and still get the same meaning for the following sql query
I want one or more felds will be equal to 1 (a = 1 OR b = 1 OR c = 1) and that keywords = 1 always
whats wrong with I did?
I want one or more felds will be equal to 1 (a = 1 OR b = 1 OR c = 1) and that keywords = 1 always
whats wrong with I did?
SELECT
count(*)
SELECT
id
FROM
ServiceRequests
WHERE (a = 1 OR b = 1 OR c = 1) AND keywords = 1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks! another quick one please Update field a to 0 in all records from 12-29-2011 until now
One way to change this syntax, but retain the same meaning, pending you clarify what the SELECT COUNT(*) SELECT id was intended to do. Let's say you start with this, though:
Another way to write this is:
SELECT
id
FROM
ServiceRequests
WHERE (a = 1 OR b = 1 OR c = 1) AND keywords = 1
;
Another way to write this is:
SELECT
id
FROM
ServiceRequests
WHERE 1 IN (a, b, c) AND keywords = 1
;
What are you trying to count, id?