一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

基于mysql中delete的语法别名问题代码示例

时间:2022-06-29 08:39:19 编辑:袖梨 来源:一聚教程网

本篇文章小编给大家分享一下基于mysql中delete的语法别名问题代码示例,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。

mysql delete的语法别名问题

首先确认,mysql中的delete语句是支持别名的;

在自己书写delete语法时候,语句如下:

delete from tableA a where a.c_pk_id = '123'

但是会报一个别名使用错误,如下:

[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'q

WHERE

q.C_PLY_NO = '1100107000404000220150000001'

AND q.N_EDR_PRJ_NO = '1'' at line 3

通过查询资料得知,mysql的delete的语法有些特殊,如下:

delete   a   from tableA  a  where a.c_pk_id = '123'

成功删除!!!

比较之后可知道,delete语句在用别名的时候要多写一个别名在delete后边

mysql delete 语句中使用别名 alias

语法:

delete  from  where ....

别名必需在 delete之后出一次。

多表间删除语法:

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

Or:

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

LEFT JOIN:

DELETE t1 FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.id IS NULL;