Search and then delete from two tables

2019-03-04 04:47发布

I have two tables which have member data (linked with 'member_id' column)

I need to search for all records where the email column ends in '.pl'. I then need to delete all records from the two tables for this (based on the 'member_id').

Is it possible to complete this in one SQL statement?

SELECT member_id
FROM exp_members 
WHERE email LIKE '%.pl'

2条回答
我想做一个坏孩纸
2楼-- · 2019-03-04 05:10
Delete from Members where Member_id = (SELECT member_id
FROM exp_members 
WHERE email LIKE '%.pl')
查看更多
迷人小祖宗
3楼-- · 2019-03-04 05:27
delete t1, t2
from exp_members t1
join table2 t2 on t1.member_id = t2.member_id
where t1.email LIKE '%.pl'
查看更多
登录 后发表回答