Skip to content
Advertisement

SQL Find column with multiple possible values

I have two tables:

TABLE 1

TABLE 2

I need the rows from Table 1 where i can have ALL values from table 2. The values from table 2 are dynamic, so i need to create a procedure to search for these possible values.

My output should be in that example:

Advertisement

Answer

You can do this by doing a join by trying to find the table 2 values in table 1. Then you can make sure all the values are getting joined. In SQL Server, something like this could work:

That being said, the way the data is structured is really bad design and you should look into fixing the data model. Hope this helps.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement