sql 联表DELETE

一、普通联表

第一个

DELETE t1, t2 FROM t1, t2, t3 WHERE t1.id=t2.id AND t2.id=t3.id;

第二个

DELETE FROM t1, t2 USING t1, t2, t3 WHERE t1.id=t2.id AND t2.id=t3.id;

对于第一个语法,只删除列于FROM子句之前的表中的对应的行。
对于第二个语法,只删除列于FROM子句之中(在USING子句之前)的表中的对应的行。作用是,您可以同时删除许多个表中的行,并使用其它的表进行搜索。

二、使用left join

DELETE d FROM  ruis_drawing as d
left join ruis_drawing_group as g on g.id = d.group_id
left join ruis_drawing_group_type as t on t.id = g.type_id
where t.id in (4,7,9,13);

上面的例子,只删除 ruis_drawing表里面的数据,如果也要删除其他表,只需要在 from 前加上要删除的表的别称。

SQL

我来吐槽

*

*

已有 10 条评论

  1. EBTBnGLvY

    10 About 22 to 25 of orally administered amisulpride is excreted in urine, mostly as the unchanged parent drug prix acheter levitra

  2. abadway

    Chen QM, et al best place to buy cialis online Figure 2a c summarize the results for each procedural step, with focus on the results of staged palliative approach

  3. abadway

    Affiliation Division of Epidemiology, Vanderbilt University Medical Center, Vanderbilt University, Nashville, Tennessee, United States of America finasteride costco

  4. abadway

    secobarbital will decrease the level or effect of guanfacine by affecting hepatic intestinal enzyme CYP3A4 metabolism cialis without a doctor's prescription Marnewick JL, Rautenbach F, Venter I, et al

  5. ingenly

    how to buy cialis Thread puffy nipples while on d bol

  6. Diusymn

    cialis super active Eating the right amount of protein and calories is important for healing, fighting infection, and having enough energy

  7. _不息

    评论邮箱通知测试