pretty much take this sample query for example:
SELECT *
FROM some_table
WHERE field1 AND field2 IN
(
SELECT field1, field2
FROM some_table
WHERE COUNT(field1) > 5
) AS subquery
)
I want field1 and field2 returned in my final result set, as the field1 and field2 returned in the result set from this inner query
SELECT field1, field2
FROM some_table
WHERE COUNT(field1) > 5
What is the right syntax here? Certainly the first query would work if I only had where field1 IN subquery
. Does field1 AND field2
even make sense here? As, I want the field1 value where field1 >5, therefore, the field2 value in that same row will already be returned?
Thanks
CodePudding user response:
This will do
SELECT *
FROM some_table
WHERE (field1, field2) IN
(
SELECT field1, field2
FROM some_table
WHERE <conditions>
) AS subquery
)