Questions tagged [sql-in]

`SQL IN` operator allows us to specify multiple values in a WHERE clause.

SQL IN operator allows us to specify multiple values in a WHERE clause.

simple syntax:

SELECT * 
FROM PERSON
WHERE ID IN (1, 5, 10)

Reference

222 questions
2
votes
1 answer

The NOT IN with NULL values dilemma in ORACLE SQL

When I used this code WHEN col1 NOT IN (SELECT col2 FROM table_name) THEN 'something' it didn't give the expected results knowing that col2 contains a NULL value, Why did this happened ? Does using IN with NULL values messes with data stored in…
Abdelrahman Emam
  • 385
  • 1
  • 6
  • 15
2
votes
2 answers

Passing Optional List argument from Django to filter with in Raw SQL

When using primitive types such as Integer, I can without any problems do a query like this: with connection.cursor() as cursor: cursor.execute(sql='''SELECT count(*) FROM account WHERE %(pk)s ISNULL OR id %(pk)s''', params={'pk':…
radoh
  • 4,554
  • 5
  • 30
  • 45
2
votes
3 answers

WHERE Column IN from parameter in DB2 over SSIS

I want to do the following command in a SSIS Package to DB2. UPDATE MyTable SET Col1 = ?, Col2 = ? WHERE Col3 IN (?) The Parameters are connected and the package is finished successfully but no row is updated. The Col3 contains values…
mburm
  • 1,417
  • 2
  • 17
  • 37
2
votes
1 answer

MySQL "ANY IN" query?

Is there any short way to do something like this in MySQL: WHERE s.loc1 IN ("A", "B", "C", "D") OR s.loc2 IN ("A", "B", "C", "D") OR s.loc3 IN ("A", "B", "C", "D"); without repeating the ("A", "B", "C", "D") bit (and preferably in such a…
M. Zoller
  • 65
  • 9
2
votes
1 answer

PostgreSQL =ANY and IN

Recently I've read Quantified Comparison Predicates – Some of SQL’s Rarest Species: In fact, the SQL standard defines the IN predicate as being just syntax sugar for the = ANY() quantified comparison predicate. 8.4 Let RVC be the…
Lukasz Szozda
  • 162,964
  • 23
  • 234
  • 275
2
votes
2 answers

How to prevent SQL Server bug in inner select expression (using 'IN' & 'EXISTS' keywords)

I have two different tables with their different columns as below: CREATE TABLE T1(C1 INT) CREATE TABLE T2(C2 INT) Every programmer knows if we write a query with wrong syntax, query compiler should give us an error. Such as this one: SELECT C1…
Merta
  • 965
  • 1
  • 11
  • 23
2
votes
1 answer

Multiple columns in, IN clause Apache Derby

I have the below SQL query: SELECT ORDER_ID, ORDER_CODE FROM ORDERS WHERE (ORDER_ID,SEQUENCE) in ((?,?)) PreparedStatement statement = connection.prepareStatement(sql) The above line of code produces a PreparedStatement object…
ht_3535
  • 363
  • 3
  • 9
2
votes
1 answer

Multiple IN Conditions on a DELETE FROM query throwing a #245 Conversion Type Error

I have a table setup like the following: Parameters ╔═══╦═════════╦════════╗ ║ID ║ Name ║ Value ║ ╠═══╬═════════╬════════╣ ║ 7 ║ first ║ 0 ║ ║ 7 ║ second ║ -1 ║ ║ 7 ║ third ║ -1 ║ ╚═══╩═════════╩════════╝ It contains more…
Dr Pepper
  • 43
  • 7
2
votes
0 answers

JPA Criteria API checking if entity collection contains certain elements or one of them

I am wondering how to create predicate which will filter entities which collection property contains elements from collection given as parameter using JPA specification. In this example I am building query for UserEntity to return users which belong…
ssukienn
  • 558
  • 6
  • 22
2
votes
2 answers

RegExp to find IN values of a SQL string

I have written a RegExp to catch all the parameters and associated values of a SQL (JDBC) query. I am using this. (?:\S+\s)?\S*"myOperatorHere\S*(?:\s\S+)? So that I can catch parameters like: Where c.value = 32 I can get c.value and 32 It works…
Gilles
  • 357
  • 3
  • 20
2
votes
1 answer

Why mysql compare "IN" as a like

I have a table with following data Table transactions trasaction_id 886 456 654_asd 898_ASDF If I use these sentence SELECT trasaction_id from transactions where transaction_id IN (886,654) I expect the result be 886, But mysql is returning…
2
votes
2 answers

SQL Server : delete where string value contains another value

I want to delete from table all records which selected string value contains in another value from another table (with ignore case sensitive). For example: if value1="Hello" (from one table) and value2-"Hello word" (from another table), then that…
Kamil W
  • 2,230
  • 2
  • 21
  • 43
2
votes
3 answers

SQL, trying to get rid of large IN cluase

I have a table, Contacts: Contact_ID (int) ContactName (nvarchar) I am given a list of contact IDs to select from. Usually, i would just do SELECT * FROM Contacts WHERE IN (List of contact ID) The problem is, the list of contact IDs could…
Vibol
  • 615
  • 1
  • 8
  • 25
2
votes
1 answer

Using decode in where clause, with "in"

Have a tricky situation in witch I belive you guys can help me out. I want to use decode in my cursors where-clause. I am using "IN()" but I belive the program thinks the comma belongs to the decode and not as a separator between values. I think…
user2362791
  • 25
  • 1
  • 2
  • 5
2
votes
1 answer

use of "in" in mongodb

I am using mongodb in vb.net I need to send more than one resource_id similar to "in" in sql. please help. My Codes are: Dim ConnString as String=ConfigurationManager.AppSettings("ConnStringMongo") Dim server As…
Syed Md. Kamruzzaman
  • 979
  • 1
  • 12
  • 33
1 2
3
14 15