我不能在sql delete中使用别名 [英] I can´t use alias in sql delete

查看:126
本文介绍了我不能在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'附近使用的正确语法 存在的地方(从撤回中选择1 在第2行的r.cod_cliente'上加入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?

sqlfiddele此处: http://sqlfiddle.com/#!2/b2771

sqlfiddele here: http://sqlfiddle.com/#!2/b2771

推荐答案

如果您使用的是别名...您必须告诉实际删除的内容(可能是因为通常只需要表别名 在多表语法中...您可以完全省略别名):

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)

请参见ALS 手册:

注意
如果为表声明别名,则在引用表时必须使用别名: 从测试AS t1,test2的地方删除t1 ...

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 delete中使用别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆