Subqueries

From Uweb

Jump to: navigation, search
This article is a Stub and you can help the uWeb group by expanding it with what you know!
Otherwise, please check out the various Stubs that need some help.

Subqueries are a method of running two or more queries within another single query to access information stored in multiple database tables. Subqueries are supported in most professional-grade RDBMS-es, including MySQL >= 4.1, MSSQL, Oracle, Postgres, and DB2.

Example:

SELECT X.*, ( SELECT username FROM users WHERE id=X.user_id ) FROM data_table X
Personal tools