1

I just want to ask if it is possible to have multiple arguments for, where clause in mysql?

Something like:

SELECT * from tblId where id=1,2,3,4

Supposed I only want to select id's 1,2,3,4. I tried this but give me error. Thanks for the help :)

4 Answers 4

7
SELECT * FROM tblId WHERE id IN (1, 2, 3, 4);
Sign up to request clarification or add additional context in comments.

Comments

2

Try this query:

SELECT * from tblId where id in (1,2,3,4)

Comments

1

Try in:

SELECT * from tblId where id in (1,2,3,4)

Comments

-4

Try this SELECT * from tblId where id =1 and id =2 and id =3 and id =4

3 Comments

id could never equal 1, 2, 3, and 4 at the same time.
You should do it with an OR instead of the AND, I guess... Anyway, this is not the optimal way.
sorry for the mistake, it should be OR. but this is the simplest if u need immediate fix or dont know the syntax of a new database for '.... in (1,2,3,4)'

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.