Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Join two tables

Author  Topic 

deanglen
Yak Posting Veteran

65 Posts

Posted - 2013-03-28 : 08:08:27
Hi I am trying to join two SQl tables to find all customers from the USA

The two tables are Customer and Address are joined by CustomerID

I tried something like this but get errors. Any idea?

Select FirstName,LastName,Email,IsRegistered,OkToEmail FROM Customer
LEFT JOIN Address
On Customer.CustomerID=Address.CustomerID
WHERE Country='USA'

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-03-28 : 08:23:38
What kind of errors did you get? Post the exact text.

Although not related to the error you are getting, if the Country column is in the Address table, you could use INNER JOIN instead of LEFT JOIN. Even if you use left join, it turns out to be an inner join because of the WHERE clause.
Go to Top of Page
   

- Advertisement -