MySQL Delete语句使用别名
问题:
在使用mySql 的 Delete 语句时,像Select 、 Update 那样使用别名时发现会报语法错误
例:
DELETE FROM t_home_reimbursement_analysis a WHERE a.CASH_TIME_ >= '2020-08-05' ;
[SQL]DELETE FROM t_home_reimbursement_analysis a WHERE a.CASH_TIME_ >= '2020-08-05' AND a.CASH_TIME_ <= '2020-08-06';
[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 'a WHERE a.CASH_TIME_ >= '2020-08-05' AND a.CASH_TIME_ <= '2020-08-06'' at line 1
解决:
mySql 的Delete语句在使用别名时,与其他语句语法有些许不一致,除了在表名后边加上别名外,还需要在Delete关键字后边也加上别名。注意:两处别名需要一致
例:
DELETE a FROM t_home_reimbursement_analysis a WHERE a.CASH_TIME_ >= '2020-08-05' ;