SQL. Different syntax to get the result?

suppose there are two tables TableA (ID INT) TableB (ID INT, TINYINT, Param).
Overlap in the ID field. Table a contains unique values, table B connection with a certain parameter.
Regard as unique. The number of relationships for each ID may be different.
Is there any other option I get ahold of records from table A which have only a certain set of parameters, except for such

select * from TableA a
where exists (select 1 from TableB b where b.id=a.id and b.Param in (x,y))
and not exists (select 1 from TableB b2 where b2.id=a.id and b2.Param NOT in (x,y))
July 9th 19 at 10:19
2 answers
July 9th 19 at 10:21
select A.* from tableA A
join tableB B on B. id=A. id and B. Param in (x,y)
such a query will return just those records that are not needed, for example, ID that have a relationship with x,y,z. - Eliane commented on July 9th 19 at 10:24
select A.* from tableA A
join tableB B on B. id=A. id and B. Param in (x,y)
left join tableB B2 on B2.id=A. id and B2.Param not in (x,y)
where B2.id is null - Lucio commented on July 9th 19 at 10:27
July 9th 19 at 10:23
SELECT * 
FROM TableA 
WHERE ID IN 
(
SELECT ID 
FROM TableB 
WHERE Param IN (x, y) 
EXCEPT 
SELECT ID 
FROM TableB 
WHERE Param NOT IN (x, y)
)

Find more questions by tags SQL Server