从三个表中删除

时间:2017-11-15 03:55:43

标签: php mysql sql yii

请那里有人
如果有任何条件或查询

我需要删除匹配的详细信息 表adl_auth_user A

id      user_id     type_id     type_value  
66428     1919          1           97  

table user_details B

user_id     first_name      last_nam    
1919        Rins TE       Kola  

表adl_user C

id         email                   password 
1919    email@DOMAIN.COM         SOME PASSWORD
  

我希望从这三个

中删除
tables table1. user_id = table2.
> user_id and table1. user_id = table3.id

和分组

  

table1.type_id,table1.type_value

1 个答案:

答案 0 :(得分:0)

试试这个。根据表依赖关系删除表中的记录。

i think grouping is not required as you are trying to delete the records


DELETE FROM adl_auth_user 
from adl_auth_user  A 
INNER JOIN user_details  B ON a.user_id=B.user_id
INNER JOIN adl_user  C ON b.user_id=c.id
WHERE A.user_id =1919 AND A.type_id =1

DELETE FROM user_details  
FROM user_details B 
INNER JOIN adl_user C ON b.user_id=c.id
WHERE B.user_id =1919 

DELETE FROM adl_user  
WHERE adl_user .id =1919