0

Is there a way to run this query to match all of these numbers without running the query 5 times? and if this is possible, how do I query these numbers if they're in a php array?

Numbers: 1, 26, 44, 45, 13

Query String:

SELECT ky, project_name FROM project WHERE ky = 1 OR 26 OR 44 OR 45 OR 13;

2 Answers 2

2

Two ways

/* ... */ WHERE ky = 1 OR ky = 26 OR /* ... */

Or you could use IN

/* ... */ WHERE ky IN (1, 26, /* etc */)
Sign up to request clarification or add additional context in comments.

Comments

0

Use IN keyword which is equallent to ORs

SELECT ky, project_name FROM project WHERE ky IN ( 1, 26, 44, 45, 13);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.