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

Oracle SQL query with CASE WHEN EXISTS subquery optimization

I'm using the following query to create a view in Oracle 11g (11.2.0.3.0). CREATE OR REPLACE FORCE VIEW V_DOCUMENTS_LIST ( …

oracle subquery query-optimization select-case
Subqueries in activerecord

With SQL I can easily do sub-queries like this User.where(:id => Account.where(..).select(:user_id)) This produces: …

ruby-on-rails-3.1 subquery arel
How to limit results of a LEFT JOIN

Take the case of two tables: tbl_product and tbl_transaction. tbl_product lists product details including names and ids …

mysql sql subquery left-join mysql-error-1054
How to update column in a table from another table based on condition?

I am having two tables student table it contains (Student_id,school_code,name,year,...) school table it contains (school_…

sql-server subquery sql-update multiple-tables
MySQL correlated subquery in JOIN syntax

I would like to provide a WHERE condition on an inner query by specifying innertable.id = outertable.id. However, MySQL (5.0.45) …

sql mysql join subquery entity-attribute-value
SUM(subquery) in MYSQL

Basically, I am trying the following: SELECT m.col1, SUM(SELECT col5 FROM table WHERE col2 = m.col1) FROM table …

mysql subquery aggregation
How do I concatenate strings from a subquery into a single row in mysql?

I have three tables: table "package" ----------------------------------------------------- package_id int(10) primary key, auto-increment package_name varchar(255) price decimal(10,2) table "zones" …

mysql list subquery group-concat concat
PostgreSQL - Using a Subquery to Update Multiple Column Values

I need to be able to update multiple columns on a table using the result of a subquery. A simple …

postgresql subquery
Selecting max record for each user

This seems if it should be fairly simple, but I'm stumbling in trying to find a solution that works for …

sql sql-server subquery
JPA/hibernate subquery in from clause

We're using JPA with hibernate as the provider, we have a query that contains a join with a subquery in …

hibernate jpa subquery