BibleGateway.com Verse Of The Day


“But he was pierced for our transgressions, he was crushed for our iniquities; the punishment that brought us peace was on him, and by his wounds we are healed. We all, like sheep, have gone astray, each of us has turned to our own way; and the LORD has laid on him the iniquity of us all.” (Isaiah 53:5-6)  listen to chapter  (Read by Max McLean. Provided by The Listener's Audio Bible.)

Powered by BibleGateway.com

Tuesday, August 18, 2009

Multiple Column Subqueries (Oracle)

I recently had to do something like this in an application, and I had to look it up to see if it was even possible. I knew you could do this with a single value, but was skeptical if multiple columns could be done this easily.

For my own benefit, I am posting the basic syntax for next time I need to do it. Replace your table names where t1 and t2 are, column names for c1, c2, c3, etc. I did this in Oracle, but it may work the same or very similar in other databases.

SELECT *
FROM t1
WHERE (c1,c2,c3)
IN (
SELECT t2.c1,t2.c2,t2.c3
FROM t2
)

For reference, I found my answer at: http://www.java2s.com/Code/Oracle/Subquery/WritingMultipleColumnSubquerieswithtablejoin.htm