x001: mysql多表的select、delete、update、Insert

多表刪除 table

delete a,b from a_table a LEFT JOIN b_table b on a.a_id=b.b_id;select

多表更新 統計

UPDATE a_table a,b_table b SET b.b_part="12dd13",a.a_name="老劉1ds" where a.a_id=b.b_id and b.b_id=5查詢

分組查詢並統計次數大於0tab

select b.b_name,count(*) as count from b_table b GROUP BY b.b_name HAVING count>0;vi

用having就必定要和group by連用,
用group by不一有having (它只是一個篩選條件用的)
相關文章
相關標籤/搜索