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)
where-in
507
questions
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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)
...
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 ...
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 ...
-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) >...
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 ...
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 ...
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 ...
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 ...
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 ...