SQL Server SELECT Where Value Equals Results of Another Select

Viewed 19368

I want to create a SQL statement to select values from one table based on the values from another. I would like to know how to do so in SQL, but knowing in PostgreSQL would be nice as well.

EX:

TableA
ID | Label | Value
1    Test    A


TableB
ID | Name | Label
1    TestN  Test

I think the query would looks something like this:

SELECT Name FROM TableB WHERE Label = SELECT Label FROM TableA WHERE Value = 'A';

That one throws errors though. Thoughts?

5 Answers
Related