Skip to content
Advertisement

Check if weak entity contains a specific value in its list of records

So what I’m trying to do is to check whether in a list of id_1’s, does it contains a specific value in its list?

e.g. Does id_1 of 1 contain a val of 10? Both the id_1 and val columns are foreign keys.

id_1  val
1     2
1     10
1     3
2     2
2     3

I am able to get to this form above, but I don’t have any idea on how to check whether id_1 contains a specific value in its list of val’s. Some tips?

Advertisement

Answer

Actually, to just check for a single value, a simple select should work here:

SELECT id_1
FROM yourTable
WHERE val = 10  -- or whatever single value for which you want to check
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement