你好,我有很大的问题。在mysql中我有3个表。 Clients
,Groups
和GroupCross
。所以我有:
SELECT * FROM clients AS cl
INNER JOIN groupscross AS cr ON cl.cid=cr.cid;
(所以现在我在groupcross中的id与客户端匹配id。在groupcross中我也有table:cgid。
现在我有来自cr.cgid的数据:50,50,60,55,60
所以当我命令:)
WHERE cr.cgid='function to get id'
。
我得到所有的cgid:(50,50,60,55,60)
这是我的问题:
如何在没有60的情况下拥有所有身份证?
我在写的时候添加:WHERE cr.cgid <>60
当我只需要50,50,55
答案 0 :(得分:1)
使用IN
声明 -
SELECT *
FROM `clients` AS `cl`
INNER JOIN `groupscross` AS `cr`
ON `cl`.`cid` = `cr`.`cid`
WHERE `cr`.`cgid` IN(50,55)