Questions tagged [where-in]

An SQL-standard condition of the form WHERE SOME_COLUMN IN (1,2,3) or using a subquery to create the list, eg WHERE SOME_COLUMN IN (SELECT X FROM MYTABLE WHERE Y)

For example:

SELECT *
FROM MY_TABLE
WHERE MY_COLUMN IN (1,2,3,5,8,13)

or commonly using a subquery to generate the list:

SELECT *
FROM MY_TABLE
WHERE MY_COLUMN IN (
    SELECT SOME_COLUMN FROM SOME_TABLE WHERE <some condition>
)

The subquery version is a source on many performance problems, because most optimizers do not optimize this properly.

Most IN (subquery) queries can be rewritten to use a join that does perform well.

497 questions
-3
votes
1 answer

DELETE FROM tab WHERE name IN ( name1 , name2 ) :fails / ok: DELETE FROM tab WHERE id IN ( 1 , 2 )

Error deleting record: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right ** syntax to use near ' name2' at line 1 ** tab: __________ id , name __________ 1 , name1 2 ,…
And
  • 73
  • 2
  • 7
-3
votes
1 answer

WHERE IN Array SQL

Update: if sched_id = 2 {Output user1,user2,user4,user5 } Can you help me with this guys..Bcoz Now when i run the code only the 1st number can be found using WHERE IN .. or is there another way to get / search value in array sql to use in WHERE..…
Jun
  • 138
  • 1
  • 9
1 2 3
33
34