mysql查詢高階用法

2022-03-12 20:55:40 字數 1030 閱讀 2577

聯合查詢

select a.* , b.adress , b.name from a , b where a.sbno = b.cdid order

bya.sbno , a.stime

select a.a_id, a.a_name, b.b_name from a a, b a where a.b_id = b.b_id //聯合查詢

insert

into table1 (xx,yy,zz) select xx,yy,zz from

table2;

select axx as id, att as name from

tb1union

select bxx as id, btt as name from

tb2整合有關聯的兩個資料表裡的字段

update tablea as ta, tableb as tb set ta.field1 = tb.field1 where ta.id =

tb.ta_id

//經典案例

(新使用者)通過表a獲取的記錄集,如下:

12012-11

-132012-11

-282012-11

-5(老使用者)通過表b獲取的記錄集,如下:

52012-11

-132012-11

-2我想將這兩個結果集合並為乙個結果集。顯示的結果如下:

日期 新使用者 老使用者

mysql高階用法

1.建立檢視 create table weather id int 11 not null auto increment,date char 24 default null,week char 24 default null,img char 128 default null,temperatur...

mysql高階查詢in MySQL高階查詢(一)

in 子查詢 巢狀查詢 重點是思路 為什麼要用in?in 在數值上相當於 但是它可以查詢到更多的符合條件的結果,等於號只可以查詢乙個結果 question 有兩種方法 第一種 使用子查詢替換表連線 使用 inner join 將表與表之間聯動,再將實現條件依次寫出來 第二種 採用子查詢 在where...

mysql 高階 查詢 MYSQL中的高階查詢

1.1.子查詢 1.1.1.在房屋型別中,如何找出比雙人間貴的所有房屋型別?找到雙人間的 根據第一步找到的 作為查詢條件去查滿足條件的房屋型別,利用where字句 子查詢是乙個巢狀在 select insert update 或 delete 語句或其他子查詢中的查詢 子查詢在where語句中的一般...