insert into Conditionid(Id,ScreenId,ConditionId)values(1,1,1); insert into Conditionid(Id,ScreenId,ConditionId)values(2,4,1); insert into Conditionid(Id,ScreenId,ConditionId)values(3,2,2); insert into Conditionid(Id,ScreenId,ConditionId)values(4,5,2); insert into Conditionid(Id,ScreenId,ConditionId)values(5,1,3); insert into Conditionid(Id,ScreenId,ConditionId)values(6,4,3);
SELECT DISTINCT ConditionId
FROM Conditionid WHERE ScreenId IN (1,4)
------解决方案-------------------- select * ftom [ConditionID] where ScreenID in(1,4) and ConditionId in (1,3)
------解决方案--------------------
------解决方案--------------------
求交集
SQL code
SELECT Conditionid
FROM Conditionid
WHERE ScreenId = 1
INTERSECT
SELECT Conditionid
FROM Conditionid
WHERE ScreenId = 4