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?
SELECT
    count(*)
SELECT
    id
FROM
    ServiceRequests 
WHERE (a = 1 OR b = 1 OR c = 1) AND keywords = 1

Open in new window

Nura111Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieAnalyst Assistant Commented:
I don't see anything wrong with your criteria, but why do you have SELECT count(*) and SELECT(id)?

What are you trying to count, id?
Kim WalkerWeb Programmer/TechnicianCommented:
Try this:
SELECT
    count(*)
FROM (
    SELECT
        id
    FROM
        ServiceRequests 
    WHERE (a = 1 OR b = 1 OR c = 1) AND (keywords = 1);
)

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nura111Author Commented:
Thanks!  another quick one please  Update field a to 0 in all records from 12-29-2011 until now
Kevin CrossChief Technology OfficerCommented:
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:

SELECT
    id
FROM
    ServiceRequests 
WHERE (a = 1 OR b = 1 OR c = 1) AND keywords = 1
;

Open in new window


Another way to write this is:

SELECT
    id
FROM
    ServiceRequests 
WHERE 1 IN (a, b, c) AND keywords = 1
;

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.