本文主要是介绍mysql delete 语句中使用别名 alias,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
今天mybatise 执行mysql delete 的时候,报错了,从"u where u.id = 1"开始报的错
delete from user u where u.id = 1;//这是错误的delete语句
delete后把要删除的表别名加上就行:
delete u from user u where u.id = 1;//这是正确的delete语句
这里搜了下,原来是delete中表的别名使用问题,以下是转载内容:
转载自:https://blog.csdn.net/chs_jdmdr/article/details/46708917
语法:
delete <alias> from <table> <alias> where <alias>.<field>...
别名必需在 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;
这篇关于mysql delete 语句中使用别名 alias的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!