In
Not in
The exists
Detect whether the object EXISTS IF the EXISTS
the EXISTS a query syntax : select * from table name where the EXISTS (a query statement)
A query returns a result: the EXISTS the subquery results to TRUE
A query without return results: the EXISTS the subquery results to FALSE, the outer query does not perform
make transcripts:
SELECT ` studentName ` name,
(SELECT ` gradeName ` FROM ` grade ` WHERE ` gradeId `=` subject `. ` gradeId `) AS courses belongs to grade , # subquery nested father grade query name
` subjectName ` course name, ` examDate ` test date, ` studentResult ` score
The FROM ` result ` r1
INNER JOIN ` student ` ON r1. ` studentNo `=` student `. ` studentNo `
INNER JOIN ` subject ` ON ` subject `. ` subjectNo `=r1. ` subjectNo `
WHERE r1. ` examDate ` IN ,
The SELECT MAX (` examDate `) FROM ` result ` r2
WHERE r1. ` subjectNo `=r2. ` subjectNo ` # parameter value between the main query and the subquery binding
GROUP BY r2. ` subjectNo `
)
the ORDER BY the subject. GradeId;
use temporary table save query results CREATE TEMPORARY TABLE TABLE name (query);
the subquery note :
Query can be nested in SQL statements of any expression in position
Only appear in the subqueries and does not appear in the parent table in the query cannot be included in the output columns