JavaCake
JavaCake

Reputation: 4115

Reducing MySQL query with multiple "OR" statements

I am doing a query where i would like to find the smartest way to define OR statements to reduce my query dump.

I have following headers in my table:

| id | subscriber | phonenumber | type |

So i wish to make a query where i only want to fetch type values equal to typeOne, typeTwoand typeThree.

Which is the smartest way?

Thanks in advance.

Upvotes: 1

Views: 1115

Answers (3)

joni_demon
joni_demon

Reputation: 666

Try to use WHERE fieldname IN (value1,value2,value3)

Upvotes: 0

Lamak
Lamak

Reputation: 70678

SELECT *
FROM YourTable
WHERE type IN ('typeOne', 'typeTwo','typeThree')

Upvotes: 0

ruakh
ruakh

Reputation: 183602

You can use an IN clause:

WHERE `type` IN ('typeOne', 'typeTwo', 'typeThree')

Upvotes: 5

Related Questions