Wednesday, April 15, 2009

Equi Join

List all accounts with their contacts

SELECT ACCOUNT_NAME, CONTACT_NAME
FROM ACCOUNT, CONTACT
WHERE ACCOUNT.ACCOUNT_ID = CONTACT.ACCOUNT_ID

SQL Server: can use INNER JOIN like that

SELECT ACCOUNT.ACCOUNT_NAME, CONTACT.CONTACT_NAME
FROM ACCOUNT INNER JOIN CONTACT ON ACCOUNT.ACCOUNT_ID = CONTACT.ACCOUNT_ID

No comments:

Post a Comment