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
1
vote
2 answers

Slick: How can I combine a SQL LIKE statement with a SQL IN statement

I basically would like to replace the following code with something more "slicky": final case class User(firstName: String, lastName: String) def dbAction(lastNameParts: Seq[String]): SqlStreamingAction[Vector[User], User, Effect] implicit val…
Stoecki
  • 585
  • 1
  • 3
  • 16
1
vote
0 answers

orientdb spring data support IN operator doesn't work

i use orientdb-spring-data library in the repository layer of my application. I have a pojo named Application with an attribute named type. I try to execute the following query: List> findByTypeIn(List type); But it…
1
vote
2 answers

SQL Where In clause with multiple fields

I have a table as below. id date value 1 2011-10-01 xx 1 2011-10-02 xx ... 1000000 2011-10-01 xx Then I have 1000 ids each associates with a date. I would like to perform something as below: SELECT…
nkhuyu
  • 840
  • 3
  • 9
  • 23
1
vote
1 answer

Mysql search in concatinated string

There is a table: CREATE TABLE n_dummy ( id int(10) unsigned NOT NULL AUTO_INCREMENT, `values` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM; INSERT INTO `n_dummy` (id, `values`) VALUES (2, '2,10'), (10, '2,10') (3, '7,3'); Look…
userlond
  • 3,632
  • 2
  • 36
  • 53
1
vote
3 answers

ORDER BY + IN statement?

The marketing department wants to focus on the customers from Noth America first. Get the ID, last name and country of all customers. Build the list by bringing up the customers living in Canada and in the USA first, and finally order them by ID.…
user6245072
  • 2,051
  • 21
  • 34
1
vote
2 answers

Can you have more than one subquery in a where clause?

I don't have an example for this but I was just wondering if something like this is valid in any situation: SELECT somefield FROM sometable WHERE something1 IN (SELECT somefield2 FROM sometable2) AND something2 IN (SELECT somefield3 FROM…
kale
  • 113
  • 1
  • 4
1
vote
2 answers

How to add an extra value to IN clause in mysql

I have an In clause with query inside. I want to add 'NULL' to that IN. How can i add. Here is my query WHERE `e`.`lead_id` IN ( select lds.lead_id from mortgage_lead_leads lds where lds.loan_officer_id=60 ) which gives 10…
chaitanya
  • 352
  • 4
  • 14
1
vote
3 answers

Using "IN" instead of "FOR" loop with a collection

I have a plsql procedure which takes an array of data and updates bunch of records, I am able to do this with a for loop. I could really use some help figuring out to do this without a loop. Package spec and body: create or replace PACKAGE…
Radan
  • 1,630
  • 5
  • 25
  • 38
1
vote
2 answers

SQL IN Operator with different comparators

I need a way to make a IN operator that makes different kind of comparisons for each parameter, that way: SELECT * FROM Table WHERE (par1, par2, par3) IN ((par1answer1, par2answer1, par3min1, par3max1), (par1answer2,…
Lucas
  • 534
  • 1
  • 10
  • 29
1
vote
2 answers

Which mySQL operator to use when checking for array of variables in a table column

I have a table column which contains a string. This string varies in length depending on the number of variables stored in it, but always follows the same pattern. The string is generated dynamically by a Wordpress plugin and I have no influence…
Richard Tinkler
  • 1,635
  • 3
  • 21
  • 41
1
vote
0 answers

SharePoint - Is it possible to achieve subqueries (SQL IN) with keywordqueries?

I was wondering if it was possible to achieve subqueries with keywordqueries? Something like this SQL query: SELECT Name FROM Production.Product WHERE ProductSubcategoryID IN (SELECT ProductSubcategoryID FROM Production.ProductSubcategory …
PlaTyPuS
  • 385
  • 3
  • 15
1
vote
2 answers

How to cast arrays to a type?

I want this query to return all ids and associated emails that are NOT returned by query #2: select my_table.id, my_table.email from my_table join another_table on my_table.id=another_table.mytable_id where my_table.id not in (select array (select…
Beth
  • 63
  • 1
  • 5
1
vote
3 answers

MySql NOT IN failing to return empty set

I am currently having a problem when trying to select where a job is listed in the tbl_jobs table and has not been assigned to a delivery item in the tbl_delivery_items table by using a NOT IN subquery. The sub query should return…
Phil Young
  • 1,334
  • 3
  • 21
  • 43
1
vote
1 answer

Subquery used as expression doesn't work

I have theses three tables I just created in Postgres: CREATE TABLE info_clients(id_client INT(pk),name VARCHAR(20), last_name VARCHAR(20)); CREATE TABLE customer_request(id_request INT(pk),client INT(fk),product INT(fk)); CREATE TABLE…
user3105533
  • 321
  • 3
  • 11
1
vote
1 answer

SQL IN Operator ERROR when array is empty

SQL IN OPERATOR I use the IN operator because I work with arrays in my SQL statement. For example: $city[1] = "'Paris'"; $city[2] = "'London'"; $cityString= implode(", ", $city); SELECT * FROM Customers WHERE City IN ($cityString); But in my…
GCallie
  • 413
  • 1
  • 3
  • 11