Top "Subquery" questions

"subquery" is vague SQL terminology, used to describe when there's either more than one `SELECT` statement in a query, or when used in Data Manipulation Language (DML) statements (IE: DELETE, UPDATE, INSERT, MERGE).

MySQL - create view using subquery in FROM clause

I want to create view in MySQL using a subquery CREATE OR REPLACE VIEW `V_TASK_TRANSFER` (`REF_ID`, `DATE_…

mysql sql subquery sql-view
ElasticSearch Join Filter: Using subquery results as filter input possible?

I have a Use Case where I want to use ElasticSearch for realtime analytics. Within that, I want to be …

join filter elasticsearch subquery term
MySQL DELETE FROM with UNION subquery by IN condition

I have tripped up on a curious SQL error. The last query doesn't work. Of course I can just split …

mysql subquery union sql-delete in-subquery
Laravel: how to use derived tables / subqueries in the laravel query builder

Edit: Though this question originally was specific for the query I'm describing underneath, the answer I got applies to almost …

php laravel subquery query-builder
Linq query with subquery as comma-separated values

In my application, a company can have many employees and each employee may have have multiple email addresses. The database …

linq subquery delimited
nhibernate queryover join with subquery to get aggregate column

I have been searching for several hours now how to do this, but can't seem to find anything to help …

nhibernate subquery queryover
Alternative to SELECT .. IN (..)

I have table with 3 columns: id (of person), city (which person visited) and date (of his visit). I need to …

sql select subquery sql-subselect
Having clause vs subquery

I could write a query using an aggregate function in two ways: select team, count(min) as min_count from …

sql subquery having
Hibernate Criteria and Count Column

I am trying to return an entity with a column that has the count of another table that is a …

hibernate count subquery hibernate-criteria
What SQL databases support subqueries in CHECK constraints?

What SQL databases, if any, support subqueries in CHECK constraints? At present and as far as I know, Oracle, MySQL, …

sql subquery check-constraints