我不能在 sql 删除中使用别名 [英] I can´t use alias in sql delete
问题描述
我试着执行这个sql语句
I tried execute this sql sentence
delete
from reclamo r
where exists ( select 1 from reclamo r
join cliente c on r.cod_cliente = c.cod_cliente
join localidad l on c.cod_localidad = l.cod_localidad
where l.descripcion = 'San Justo');
删除圣胡斯托"镇的客户提出的所有索赔但它说错误代码:1064.您的 SQL 语法有错误;请检查与您的 MySQL 服务器版本相对应的手册,以了解在 'r 附近使用的正确语法哪里存在(从 reclamor 中选择 1在第 2 行的 r.cod_cliente' 上加入客户 c"有谁知道我如何解决这些错误?
for remove all the claims made by customers of the town of 'San justo' but it says "Error Code: 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 'r where exists ( select 1 from reclamo r join cliente c on r.cod_cliente' at line 2" anyone know how I can fix these errors?
sqlfiddle 在这里:http://sqlfiddle.com/#!2/b2771>
sqlfiddele here: http://sqlfiddle.com/#!2/b2771
推荐答案
如果您使用别名... ÿou 必须告诉实际删除什么(可能这是因为通常只需要表别名 在多表语法中...你可以完全省略别名):
If you're using aliases... ÿou have to tell what to actually delete (probably this is because table aliases are usually only needed in multiple table syntax... you could just omit the alias altogether):
mysql> delete from tablename r;
ERROR 1064 (42000): 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 'r' at line 1
mysql> delete r from tablename r;
Query OK, 0 rows affected (0.00 sec)
参见手册:
注意
如果为表声明别名,则在引用表时必须使用别名:从 test AS t1, test2 WHERE ...
Note
If you declare an alias for a table, you must use the alias when referring to the table: DELETE t1 FROM test AS t1, test2 WHERE ...
这篇关于我不能在 sql 删除中使用别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!