Skip to main content

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)

0 votes
0 answers
13 views

Find value from an array in a MySQL JSON column [duplicate]

I have the following table contents ID (int) | ArrayValues (JSON) ----------------------------- 1 | [7,13,15] 2 | [4,8,12] 3 | [15,16,23] I want to get all the rows that contain ...
TheHvidsten's user avatar
  • 4,259
0 votes
0 answers
26 views

MYSQL Where IN not working if the parameter is taken/converted from json string [duplicate]

I have a table something like this id name 1 A 2 B 3 C I'm trying to filter it by using WHERE IN from a json string with something like this: SELECT id, name FROM ref_finding_criterias WHERE id ...
IkouKuhn's user avatar
0 votes
2 answers
39 views

Oracle SQL : different where clauses with respect to the different variables in a single clause

CATEGORY DATE(DD.MM.YYYY) a 01.01.2024 a 02.01.2024 a 03.01.2024 a 04.01.2024 a 05.01.2024 b 01.01.2024 b 10.01.2024 b 15.01.2024 c 01.01.2024 c 11.01.2024 c 25.01.2024 I am trying to get ...
DataQuery's user avatar
0 votes
2 answers
71 views

'where name not in' is based on the results of a previous query

I am attempting to gather two opposing lists, based on a WHERE-IN list. Sorry if the term isn't correct, but it'll at least be consistent though out the post. WHERE name IN ('name1') I have a select ...
Kurt Schwob's user avatar
0 votes
3 answers
62 views

How to use CASE condition in WHERE in PostgreSQL?

I have a Spring boot app with custom queries. I need to find all database rows according to condition - if :myFlag is true, field in database must be in a list (:values here), or null. Can I use ...
programmer's user avatar
0 votes
2 answers
32 views

How to select a column for a where statement based on another column value in SQL?

I'm currently beginning a project for which i need to do some data management in SQL. I want to check wether i have enough history for an individual to be included in the analysis I extracted data in ...
sqlbeginner0's user avatar
0 votes
1 answer
66 views

SQL : unrecognized name

Unrecognized name: year at [6:7] SELECT EXTRACT(YEAR FROM starttime) AS year, COUNT (*) AS number_of_rides FROM bigquery-public-data.new_york.citibike_trips WHERE year IN (2013,2014) ...
Amirul Fakhruddin's user avatar
0 votes
1 answer
85 views

How to get a table with NULL values from a PostgreSQL INNER JOIN and UNION ALL query?

I have a PostgreSQL query for a time series graph with an inner join. A list of tags is used as a where condition for the inner join. I use union all to get a result table with data from two cases: a ...
jvkloc's user avatar
  • 789
0 votes
1 answer
282 views

Why is empty subquery in SQL IN sometimes treated as null

I noticed the following strange behavior in SQL Server SELECT * FROM Tbl WHERE col NOT IN ((SELECT 1 WHERE 1 = 2)) returns all records (i.e. the subquery result is the empty set) while SELECT * FROM ...
adrianm's user avatar
  • 14.6k
-1 votes
1 answer
59 views

SELECT rows from my table where the start and end times are within my shift ranges

SELECT [Machine_Events_ID], [Event_TimeStamp], [Event_EndTimeStamp], [Bucket_ID], [PartNumber] FROM [A5].[dbo].[Machine_Events] WHERE DATEPART(hour, Event_TimeStamp) >...
BigSchottkyD's user avatar
0 votes
2 answers
495 views

Place quotes & add comma around many items in WHERE

I have a very long list of codes for a WHERE statement in SQL Server that I would like to 'quickly' add quotes around each one and a comma at end of each one. I would like to take the huge list like ...
KLR's user avatar
  • 61
0 votes
1 answer
13 views

I need the query to only show count(sku) > 10

How can I add up the totals from a column I've already asked to sum up? select --distinct batch_date, bol_nbr, cur_opr, lane_nbr, size_code, sku loc_code, ship_lab, size_code, sku, COUNT(SKU) from ...
Anthony Armendariz's user avatar
0 votes
1 answer
62 views

Run query efficiently with a long list for IN operator with WHERE clause in Big Query

I have a situation where I need to move some data from one table to another in bigquery with some processing in middle. I have created a pipeline with Node.js client library which runs query for each ...
trempus2all's user avatar
0 votes
3 answers
183 views

Where Year In list of years Laravel

What I want to do is something like this : $listOfYears = Invoice::pluck('year') ; // [ 2001, 2002, 2003 ] $products = Product::whereYearIn('purchase_date',$listOfYears)->get(); the field ...
Yasser CHENIK's user avatar
0 votes
0 answers
40 views

How to create Layered SELECT statement with JPA

I am attempting to make a query through the User table with a standard CrudRepository that returns each ChessGame associated with the Players associated with the User. User entity has a @OneToMany ...
dbrewster's user avatar
  • 693

15 30 50 per page
1
2 3 4 5
34