I have 2 tables which name users and images in mysql.
users has : id , name, password
images has : id, kid, imagePath
kid = id.
When the admin delete user in users, i want to delete images too, if has.
my sql statement is :
"DELETE FROM users u LEFT JOIN images i ON i.kid = u.id WHERE u.id = '{$id}'";
This statement returns false. How can i fix it?
If you want to delete from two tables, try this syntax:
DELETE u, i
FROM users u LEFT JOIN
images i
ON i.kid = u.id
WHERE u.id = '{$id}';
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.