2

我将从 2 个表中删除数据。我会这样做:

 DELETE FROM dc_mail_users u, dc_mail_user_data d WHERE u.i_id_pk = 3 AND d.i_id_ut = u.i_id_pk

但这会返回 SQL 语法错误。如何通过 SQL AS 语句解决此问题?就像下面的例子一样。

SELECT first_name.last_name AS name WHERE name="John Doe"
4

3 回答 3

3
DELETE u, d
FROM dc_mail_users u
INNER JOIN dc_mail_user_data d
    ON d.i_id_ut = u.i_id_pk
WHERE u.i_id_pk = 3
于 2012-04-06T10:21:13.750 回答
2
delete u, d
FROM dc_mail_users u
join dc_mail_user_data d
on d.i_id_ut = u.i_id_pk
and u.i_id_pk = 3 
于 2012-04-06T10:20:47.620 回答
2

您的原始语句也是正确的如果您添加表的别名,一个示例SQL Fiddle

于 2012-04-06T21:01:58.317 回答