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

How are IN expressions executed in SQL queries internally?

I have query with an IN clause. select * from student where id in (1, 2, 3, 4, 5) How will the engine parsed and execute this SQL query? Is it like this, parsed in five different queries or something else? select * from student where id = 1 select…
2
votes
3 answers

Why does num IN("num1,num2") atop at first comma?

Here is my pseudo query: SELECT col1, col2 FROM table WHERE number IN(number1,number2,number3); EXAMPLE SELECT name, description FROM products WHERE 5 IN(category_id); NOTE: Let's assume that one of the rows in the table has category_id =…
2
votes
0 answers

SQL IN Statement - Value In (database_field)

Part of a search query i'm building requires filter values to be processed through an SQL query to check against a CSV list within a database field. (I have no control over the use/non use of CSV lists within database fields, working with what i…
Banny
  • 811
  • 4
  • 13
  • 36
2
votes
2 answers

IN query in SQL Server

Is this structure with IN is right or wrong this gives me error SELECT TblProjectResources.UserId FROM TblTasks,TblProjectResources WHERE TblTasks.ProjectId=TblProjectResources.ProjectId AND TblTasks.TaskId=@TaskId AND…
2
votes
3 answers

unexpected token: VALUES near line 1, column 57

JPA.em("default").createQuery("insert into USER (FULLNAME, EMAIL, USERNAME, PASSWORD) " + " VALUES (\'"+fullname+"\',\'"+email+"\',\'"+username+"\',\'"+password+"\');"); is it a wrong query? i get this error: [IllegalArgumentException:…
doniyor
  • 36,596
  • 57
  • 175
  • 260
1
vote
2 answers

SQL Server 2005 - DataType of variable to store a RowSet

In a typical stored procedure i am working there are various checks with the same query as below. SELECT ... FROM Projects WHERE ProjectId IN (SELECT ProjectId FROM Tasks) i would like to replace the query (SELECT ProjectId FROM Tasks) with a…
Deeptechtons
  • 10,945
  • 27
  • 96
  • 178
1
vote
1 answer

SQL query for items joined to multiple categories

I've got these 2 tables, content item and a join table to categories. I simply need a query to select items that are in multiple categories (in ALL categories, not in any category). -- content items CREATE TABLE `items` ( `id` bigint(20) NOT NULL…
scms
  • 93
  • 1
  • 6
1
vote
1 answer

How to make a Query for seaching two different data string in two different columns?

Now I had made a Table say PinDistance in MySQL with Columns PinCode1, PinCode2, Distance. And I have a record like this. ------------------------------------- | PinCode1 | PinCode2 | Distance…
bonny
  • 688
  • 1
  • 14
  • 33
1
vote
2 answers

How can I make an intersection of two columns of two tables and get the entire rows?

I have a SQLite table. Let's call it people. Name Age Jane 50 John 80 Alice 46 Mark 25 Harry 33 I have another table work. Name work_id Jane 1 Amanda 2 Filip 3 Alice 4 Jack 5 Harry 6 I'd like to get all rows…
user13840624
  • 133
  • 8
1
vote
1 answer

Using 'not is in' in PySpark and getting an empty dataframe back

I'm trying to use filter to find those 'title' that are not in list_A. A = B.groupBy("title").count() A = A.filter(A['count'] > 1) A_df = A.toPandas() list_A = A_df['title'].values.tolist() B.filter(~B.title.isin(list_A)).count() However, I get an…
Lucas
  • 25
  • 6
1
vote
2 answers

Error while executing SQL query on database: misuse of aggregate: count()

SELECT title FROM film WHERE film_id in ( SELECT count(inventory.inventory_id) as counter FROM inventory WHERE film_id = film.film_id and counter = 8 ) I am trying to display all movie titles from 'film' that have exactly 8 copies…
alex
  • 13
  • 2
1
vote
2 answers

Select rows according to another table with a comma-separated list of items

Have a table test. select b from test b is a text column and contains Apartment,Residential The other table is a parcel table with a classification column. I'd like to use test.b to select the right classifications in the parcels table. select *…
ziggy
  • 1,488
  • 5
  • 23
  • 51
1
vote
1 answer

Get all entries without a specific value in One to Many relationship SQL

I have a Exercise table, and a Tag table. Each exercise can have several tags so I have a third table for the one to many relationship. What I try to achieve is getting all the exercises that does NOT have a specific tag. Data example: Exercise…
1
vote
1 answer

Is it possible to select rows where the occurences of an id is > some value OR the value of a column is > some value?

Given a table: userid activity count 1 RoomC 4 2 RoomB 1 2 RoomB 1 2 RoomC 1 3 RoomC 1 3 RoomC 1 3 RoomC 1 3 RoomC 1 4 RoomC 1 4 RoomC 1 Im trying to select the rows where a userid shows up more then X number of times,…
Mark
  • 3,653
  • 10
  • 30
  • 62
1
vote
1 answer

Is it possible to select rows where the occurences of an id is > some value?

Given a table: userid activity location 1 RoomC 1 2 RoomB 1 2 RoomB 2 2 RoomC 4 3 RoomC 1 3 RoomC 5 3 RoomC 1 3 RoomC 5 4 RoomC 1 4 RoomC 5 Im trying to select only the rows where a userid shows up more then X number of…
Mark
  • 3,653
  • 10
  • 30
  • 62