聯表刪除:
1、從資料表t1 中把那些id值在資料表t2 裡有匹配的記錄全刪除掉
delete t1 from t1,t2 where t1.id=t2.id 或delete from t1 using t1,t2 where t1.id=t2.id
2、從資料表t1裡在資料表t2裡沒有匹配的記錄查詢出來並刪除掉
delete t1 from t1 left join t2 on t1.id=t2.id where t2.id is null 或
delete from t1,using t1 left join t2 on t1.id=t2.id where t2.id is null
3、從兩個表中找出相同記錄的資料並把兩個表中的資料都刪除掉
delete t1,t2 from t1 left join t2 on t1.id=t2.id where t1.id=25
MySQL聯表查詢及聯表刪除的方法
mysql聯表查詢及聯表刪除都是經常需要用到的操作,下面對mysql聯表查詢和聯表刪除都作了詳細的介紹分析,希望對您有所幫助。mysql聯表查詢 reference mysql manul 3.2.7.select語法13.2.7.1.join語法 13.2.7.2.union語法 eg1 mysq...
mysql聯表速查
select a.b.from a inner join join b on a.id b.id select a.b.from a left join b on a.id b.id select a.b.from a left join b on a.id b.id where b.id is n...
MySQL聯表查詢
顯示所有員工名字 emp.ename 員工工資 emp.sal 及所在部門的名字 dept.dname 笛卡爾積 emp num dept num 聯表查詢時一定要帶上關聯條件 select ename,sal,dname from emp,dept where emp.deptno dept.de...