我有三个表tblClients
,tblClientsActivities
和tblActivities
tblClients
和tblClientsActivities
联合起来制作下面的表A
SELECT * from tblClientsActivities
left join tblclients on tblClientsActivities.fk_cid=tblclients.pk_cid
PK_AID FK_CID FK_AID
1 4 1
2 4 2
3 4 4
4 5 1
5 5 3
6 5 5
7 6 1
8 6 2
9 7 6
10 8 3
问题是如何删除所有FK_AID<>的客户端? 1
答案 0 :(得分:0)
简单使用WHERE
子句。
SELECT * FROM tblClientsActivities
LEFT JOIN tblclients on tblClientsActivities.fk_cid=tblclients.pk_cid
WHERE FK_AID <> 1
答案 1 :(得分:0)
使用WHERE子句中使用的限制:
SELECT * from tblClientsActivities
left join tblclients on tblClientsActivities.fk_cid=tblclients.pk_cid
where FK_AID != 1