I will delete data from 2 tables. I will do it as follow:
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
But this will return a SQL syntax error. How can I fix this whit the SQL AS statement? Just like the example below.
SELECT first_name.last_name AS name WHERE name="John Doe"
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
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
Your original statement would also be correct If you add the alias of the tables, an example SQL Fiddle
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.