I can´t use alias in sql delete

前端 未结 2 862
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-19 17:44

I tried execute this sql sentence

delete 
        from reclamo r
        where exists ( select 1 from reclamo r
                        join cliente c on r.c         


        
2条回答
  •  执笔经年
    2021-01-19 18:36

    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)
    

    See als the manual:

    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 ...

提交回复
热议问题