kale
kale

Reputation: 133

Can you have more than one subquery in a where clause?

I don't have an example for this but I was just wondering if something like this is valid in any situation:

SELECT somefield
FROM sometable
WHERE something1 IN (SELECT somefield2 FROM sometable2)
  AND something2 IN (SELECT somefield3 FROM sometable3)

Upvotes: 1

Views: 140

Answers (2)

Bohemian
Bohemian

Reputation: 424973

Yes. Your syntax needs to be fixed though:

SELECT somefield
FROM sometable
WHERE something1 IN (SELECT somefield2 FROM sometable2)                        
AND something2 IN (SELECT somefield3 FROM sometable3)

Upvotes: 0

Mureinik
Mureinik

Reputation: 310993

In a word - yes. You can have as many conditions as you want in a where clause, regardless of whether they have in conditions or not.

Upvotes: 1

Related Questions