Reputation: 4918
I need to select records that has ID = 10,23,30 so I wrote this SQL
Select * from mytable where position(id in '10,23,30') > 0
But the problem I get additional records where ID = 1 and 2 Any ideas how to select only what I need ?
Upvotes: 1
Views: 72
Reputation: 24609
Use IN
operator:
Select * from mytable where id in (10,23,30)
Upvotes: 3
Reputation: 44795
No need for position
, just do IN
:
Select * from mytable
where id in (10,23,30)
Upvotes: 6