Tony
Tony

Reputation: 12705

SQL query - select row basing on the joined table's criteria

I'm stuck within this simple scenario:

tableA

| ID | TableB_ID | Name |

tableA 1 ---> * tableB

tableB

| ID | Status_ID |

and I need to retrieve the Name column values from the tableA, whose contains rows in the tableB with Status_ID = 1 and Status_ID = 2 (two separate rows, it can be more with other values but it doesn't matter here)

Upvotes: 0

Views: 35

Answers (1)

user5470500
user5470500

Reputation:

Try this:

SELECT A.NAME
    FROM TABLE_A AS A INNER JOIN TABLE_B AS B ON A.TABLEB_ID = B.ID
    WHERE B.STATUS_ID IN (1, 2) -- OR OTHER VALUES

Upvotes: 2

Related Questions