user2339970
user2339970

Reputation: 47

SQL statement, nested in query with two keys

SELECT * FROM TAB1 WHERE (ID1,ID2) IS IN (SELECT ID1,ID2 FROM TAB2)

ID1 and ID2 is two primary key for TAB1 and TAB2, we can do it with single primary key but how to do with 2 primary key

Upvotes: 1

Views: 76

Answers (1)

Quassnoi
Quassnoi

Reputation: 425341

SELECT  *
FROM    tab1
WHERE   EXISTS
        (
        SELECT  NULL
        FROM    tab2
        WHERE   tab2.id1 = tab1.id1
                AND tab2.id2 = tab1.id2
        )

Upvotes: 2

Related Questions