SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Join two tables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

deanglen
Yak Posting Veteran

58 Posts

Posted - 03/28/2013 :  08:08:27  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3334 Posts

Posted - 03/28/2013 :  08:23:38  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000