smriti
smriti

Reputation: 115

SQL query to retrieve data from one table depending on data stored in another table?

There are 3 tables: table1, table2 and table3.

The query is:

select column1 from table1 where variable1=@value1 AND variable2=@value2

Here, value1 and value2 are the whole data stored in tables table2 and table3

Upvotes: 0

Views: 347

Answers (2)

CyberDude
CyberDude

Reputation: 8949

The question is not very clear but the closest guess would be

SELECT column1
FROM table1
JOIN table2 ON table1.variable1 = table2.value1
JOIN table3 ON table1.variable2 = table3.value2

Upvotes: 2

roman
roman

Reputation: 117337

try this

select colum1
from table1
where
    variable1 in (select column2 from table2) and
    variable2 in (select column3 from table3)

Upvotes: 1

Related Questions