时间:2021-07-01 10:21:17 帮助过:13人阅读
mysql多表删除用上面的语句会报sql syntax语法错误的,报错如下。
[SQL]
delete from users u,country c where u.id = c.userId and u.id = 20
[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 ‘u,country c where u.id = c.userId and u.id = 20‘ at line 1
mysql多表删除数据正确的方法应该使用内连接来删除,如下两条语句,可任选一句。
//语句一 delete u,c from users u INNER JOIN country c on u.id = c.userId and u.id = 20 //语句二 delete u,c from users u INNER JOIN country c where u.id = c.userId and u.id = 10
这个时候你一定会认为,oracle删除多表数据能否用上面这两条语句?答案是:不行!,它会报如下错误。
“ORA-00933:SQL命令未正确使用”
说明oracle使用上面的两条语句多表删除数据是不行的,那oracle多表删除数据该怎么写呢?命令如下。
//oracle中只能分开执行 delete from users where users.id = 20 delete from country where country.userId = 20
在oracle中不能进行多表关联删除,这可能跟oracle数据库的安全机制有关,你只能把上面的语句分成两条sql语句来执行才可以实现oracle的多表删除。
转自 :http://www.tpyyes.com/a/mysql_oracle/2017/1116/383.html
Oracle 多表联合删除?--转
标签:none com for microsoft 这一 targe family users near