子查询作为计算列:子查询的一个最简单的形式就是内部查询为外部查询的每行返回一个单值结果,他通常作为一个结果插入到一个计算列。select columnA ,(子查询)AS columnB from 表名;
where子句中的子查询:select columnA from TableA where columnB = (子查询);比如在实际中:select examId,studentOn from exam where studentOn <= (select studentOn from exam where examId = 5) order by studentOn desc;
返回多个结果的子查询:当子查询返回多行时,我们可以用in关键字来解决上面出现的问题。select 列A,列B from table1 where 列C in (select 列D from table2);(未完待续)