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).

Subquery returned more than 1 value.This is not permitted when the subquery follows =,!=,<,<=,>,>= or when the subquery is used as an expression

I have a stored procedure that select * from book table , using sub query my query is USE [library] GO /****** Object: …

sql-server subquery
How to delete from select in MySQL?

This code doesn't work for MySQL 5.0, how to re-write it to make it work DELETE FROM posts where id=(SELECT …

sql mysql select uniqueidentifier subquery
How can I insert values into a table, using a subquery with more than one result?

I really would appreciate your help. Probably it's a quite simple problem to solve - but I'm not the one .. ;…

sql insert subquery
JPA 2.0, Criteria API, Subqueries, In Expressions

I have tried to write a query statement with a subquery and an IN expression for many times. But I …

jpa subquery jpa-2.0 criteria-api in-subquery
SQL Joins Vs SQL Subqueries (Performance)?

I wish to know if I have a join query something like this - Select E.Id,E.Name from …

sql performance sql-server-2008 subquery join
subquery in FROM must have an alias

I have this query I have written in PostgreSQL that returns an error saying: [Err] ERROR: LINE 3: FROM (SELECT DISTINCT (…

sql oracle postgresql subquery
PostgreSQL 'NOT IN' and subquery

I'm trying to execute this query: SELECT mac, creation_date FROM logs WHERE logs_type_id=11 AND mac NOT IN (…

postgresql subquery
Is there a performance difference between CTE , Sub-Query, Temporary Table or Table Variable?

In this excellent SO question, differences between CTE and sub-queries were discussed. I would like to specifically ask: In what …

sql sql-server tsql subquery common-table-expression
MySQL DELETE FROM with subquery as condition

I am trying to do a query like this: DELETE FROM term_hierarchy AS th WHERE th.parent = 1015 AND th.…

mysql sql subquery sql-delete in-subquery
Postgres Error: More than one row returned by a subquery used as an expression

I have two separate databases. I am trying to update a column in one database to the values of a …

sql database postgresql subquery dblink