Questions tagged [in-clause]

The IN clause of a SQL query is a function, generaly used within a WHERE clause, that returns true if a value is in a given set. Use for questions relating to this clause.

The IN clause of a SQL query is a function, generaly used within a WHERE clause, that returns true if a value is in a given set. For example,

SELECT *
FROM foo
WHERE bar IN(24, 37, 82);

will only return rows from foo if bar is either 24, 37, or 82.


More examples:

SELECT foo
FROM (SELECT 27 AS FOO FROM dual)
WHERE foo IN(35, 45, 26, 98, 27)

returns 27

SELECT foo
FROM (SELECT 64 AS FOO FROM dual)
WHERE foo IN(35, 45, 26, 98, 27)

returns no data found

257 questions
-2
votes
2 answers

Multiple Id's in In clause of SQL Query C#

I want to basically use multiple iD's in In clause of my sql query. Now i have two options one is to get the comma separated ID's from a textbox or i can put a list view or grid view to insert id's there and then get the id's to be used in sql…
Bilal
  • 21
  • 1
  • 9
-3
votes
3 answers

Find similar records in the same table

I am looking for similar records in the same table. I tried IN clause (below query) but it is not working as per the expectation. Select * from tblBlogCategory Where CategoryID IN (Select CategoryID from tblBlogCategory Where BlogID=1) i.e. I have…
Jeeten Parmar
  • 5,568
  • 15
  • 62
  • 111
1 2 3
17
18