amar
amar

Reputation:

how to use ALL clause in mysql

i trying to fetch records from database as.

select * from emp_marks where sub_id all(2,4);

Upvotes: 0

Views: 760

Answers (2)

Michael Krelin - hacker
Michael Krelin - hacker

Reputation: 143071

If you want the records where sub_id is either 2 or 4, you need

SELECT * FROM emp_marks WHERE sub_id IN (2,4);

if you want to records where sub_id is both 2 and 4, you don't have to perform query at all ;-)

Upvotes: 1

Wael Dalloul
Wael Dalloul

Reputation: 22994

you can't use all with where clause, if you want to get all the records that have sub_id = 2 or 4 you can use:

select * from emp_marks where sub_id in (2,4)

Upvotes: 2

Related Questions