mysql子查詢的幾種常見寫法:
復制代碼 代碼如下:
select * from xxx where col = [any|all](select * from xxxx);
復制代碼 代碼如下:
select * from xxx where col in (select * from xxxx);
復制代碼 代碼如下:
select row(value1,value2.....) = [any](selectcol1,col2..);
復制代碼 代碼如下:
select .... where col = [not] exists (select......);
復制代碼 代碼如下:
select .... from (select .....) as name where ......
子查詢雖然挺方便,但其有不少缺點,其不支持limit,而且經實驗證明其執行效率相當不理想,在一般的情況下,還是不推薦是用子查詢。
新聞熱點
疑難解答