資料庫之多表查詢(連線查詢)

2021-07-25 08:26:22 字數 462 閱讀 3799

一:非等值和等值的多表查詢

select c.catname '圖書類別',b.bookname '書名',b.price '**' from cats c,book b;

select c.catname '圖書類別',b.bookname '書名',b.price '**' from cats c,book b where c.id=b.catid;

二:自身連線查詢

select cs1.catname '父類別名稱',cs2.catname '子類類別名稱' from cats cs1,cat2 cs2 where cs1.id=cs2.pid;

三:復合連線查詢

多個條件使用「and」關鍵字連線即可。

oracle資料庫之多表查詢

select s.stuid,s.stuname,s.stuage,s.gender,cl.classesname from student s,classes cl where s.classesid cl.classesid select s.stuid,s.stuname,s.stuage,s...

資料庫多表連線查詢

一 多表查詢 多表查詢,又稱表聯合查詢,即一條sql語句涉及到的表有多張,資料通過特定的連線進行聯合顯示。1 笛卡爾積 在數學中,兩個集合x和y的笛卡尓積 cartesian product 又稱直積,表示為x y.假設集合a 集合b 則兩個集合的笛卡爾積為。在資料庫中,如果直接查詢倆張表,那麼其查...

MySQL資料庫 多表連線查詢

多表連線查詢 注意 使用連線技術建議將表經行重新命名!explain 檢索連線是否達標 內連線 語法1 from 表1 inner join 表2 on 主鍵字段 外來鍵字段 where 條件表示式 語法2 from 表1,表2 where 主鍵字段 外來鍵字段 and 條件表示式 三個表連線 fr...