日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

子查询

發布時間:2024/4/17 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 子查询 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

13.7.1 轉子查詢為內連接

select name from country

where code in (select countrycode from countrylanguage);

1.移動CountryLanguage表到From支局

2.這where語句表這代碼列和返回的country代碼列比較,轉換In表達式為明確的比較在country代碼列。

select name from country,countryLanguage

where code =countryCode;

為了列出唯一的名字select distinct name from country,countryLanguage where code=contrycode;

13.7.2 轉換子查詢到外連接

select name from country where code not in(select coutrycode from countryLanguage);

1.移動countrylanguage到from語句和使用left join

2.where語句比較代碼列和子查詢的代碼列進行比較。轉換In表達式到一個明確的在country代碼列在from語句

3.在where語句,限制輸出到這些行有NULL

select name from country left join countrylanguage on code=contrycode where countrycode is null;

也可以轉換為右外連接

select from countrylanguage right join country on countrycode =code where countrycode is null;

13.8 使用子查詢在updates中

create table NACities select * from city where countryCode in (select code from country where continent ='North America');

DELETE from NACities where CountryCode IN(select code from country where lifeExpectancy <80);

注意:MYsql does not allow a table that is being updated in the outer query to be selected from in any subquery of the statement.如下:

delete from NACities where ID IN (select ID from NACites where Population <500);You can't specify target table 'NACities' for update in FROM clause


總結

以上是生活随笔為你收集整理的子查询的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。