Table A
Token
AA BB CC DD
Table B
TableA_Token Key Value AA Method Virtual AA App Y AA Manual Y AA Stored N BB Method Physical BB App Y BB Manual Y BB Stored N CC Method Virtual CC App N CC Manual N CC Stored N DD Method Virtual DD App N DD Manual N DD Stored N
select a.token from TableA a left join TableB b on b.TableA_Token = a.Token where (b.key = 'Method' and b.value = 'Virtual') and (b.key in ('App', 'Manual', 'Stored') and b.value = 'N');
Need to retrieve all the tokens where method is Virtual and the value for all of these 3 keys (App, Manual, Stored) is N.
Result:
CC DD
The above query is not returning the data as expected.