sql子查詢

select cust_name, cust_state, (select count(*) from orders where orders.cust_id=customers.cust_id) as orders from customers  order by cust_name;



開始執行,找出customers的第一條記錄,然後在執行子查詢,這個時候customers.cust_id就是一個值,將子查詢全部執行完後,在執行外部查詢。。。。。。。。  這個地方因爲用的是子查詢,所以不用使用join

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章