Peter
Peter

Reputation: 2759

Select query on a Table based on condition from other table ? No Foreign key

I want to make a select query from table A if a different select query returns from table B. Query in table can be select 1 from B where x= something. Query in Table A can be entirely different.

Can i do this in a single SQL query ? What is the best way to achieve this ?

I am using postgres

Upvotes: 0

Views: 314

Answers (1)

GarethD
GarethD

Reputation: 69769

By the sounds of it you want something like:

SELECT  A.SomeColumn, A.AnotherColumn
FROM    A
WHERE   EXISTS (SELECT 1 FROM B WHERE B.X = Something);

Upvotes: 1

Related Questions