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

Difference between CTE and SubQuery?

From this post How to use ROW_NUMBER in the following procedure? There are two versions of answers where one …

sql sql-server tsql subquery common-table-expression
Efficient latest record query with Postgresql

I need to do a big query, but I only want the latest records. For a single entry I would …

sql postgresql subquery distinct
SQL join subquery

I tried searching for an answer to my problem but failed to get an answer that actually helped. I've written …

sql oracle join subquery
How to specify the parent query field from within a subquery in mySQL?

Is there a way to specify the parent query field from within a subquery in mySQL? For Example: I have …

php mysql subquery parent-child
mysql subquery inside a LEFT JOIN

I have a query that needs the most recent record from a secondary table called tbl_emails_sent. That table …

mysql subquery left-join
MYSQL update with WHERE SELECT subquery error

I have an issue with getting select sub-queries to work on an UPDATE. I'm trying something like the following: UPDATE …

mysql select subquery
MYSQL UPDATE with IN and Subquery

Hi i have tables like this : table entry : id | total_comments _____________________ 1 | 0 2 | 0 3 | 0 4 | 0 table comments : id | eid | comment _____________________ 1 | 1 | comment sdfd 2 | 1 | testing testing 3 | 1 | …

mysql sql-update subquery sql-view
LEFT OUTER JOIN with subquery syntax

I am learning SQL trough a GalaXQL tutorial. I can't figure out the following question (Exercise 12): Generate a list of …

sql subquery outer-join
Example of an Oracle PIVOT clause with subquery

Oracle's definition of the PIVOT clause specifies that there is a possibility to define a subquery in the IN clause. …

sql oracle syntax subquery pivot
Why is there a HUGE performance difference between temp table and subselect

This is a question about SQL Server 2008 R2 I'm not a DBA, by far. I'm a java developer, who has …

sql sql-server-2008-r2 subquery query-performance temp-tables