sql巢狀查詢語句

2021-04-13 09:29:04 字數 838 閱讀 5638

use adventureworks ;

goselect distinct c.lastname, c.firstname

from person.contact c join humanresources.employee e

on e.contactid = c.contactid where employeeid in

(select salespersonid

from sales.salesorderheader

where salesorderid in

(select salesorderid

from sales.salesorderdetail

where productid in

(select productid

from production.product p

where productnumber like'fw%')));

goselect emp.empno,emp.ename,emp.job,emp.sal from scott.emp where sal>=(select sal from scott.emp where ename='ward'); 

select * from company

where age = ( select age from company

where name = taihang)

select emp.empno,emp.ename,emp.job,emp.sal from scott.emp where sal in (select sal from scott.emp where ename='ward');

多個sql語句巢狀查詢

法一 設定 connection連線 multiplestatements true 儲存查詢的sql語句的陣列 let sqlarr 儲存查詢結果的物件 let resobj async.eachseries sqlarr,function item,callback resobj item ro...

SQL巢狀查詢

訂單表orders 顧客表 customers 訂單商品表orderitems 列出訂購物品rgan01的所有顧客 select cust name,cust contact from customers where cust id in select cust id from orders whe...

資料庫基本SQL語句 巢狀查詢

查詢科目名稱為 語文 的所有科目成績 select from scores where subject id in select id from subject where names 語文 在where子句中對於能巢狀的子查詢的數目沒有限制,不過在實際使用時由於效能的限制,不能巢狀太多的子查詢,對...