Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi!My Left Table looks like this:CustomerIDCustomerCompanyNameCustomerVisitAddressLine1CustomerVisitAddressLine2CustomerVisitAddressZipCodeIDCustomerPostalAddressLine1CustomerPostalAddressLine2CustomerPostalAddressZipCodeID... and my right table ...ZipCodeIDPlaceSo my problem is that I have two different ZipCodeID's for each record in the left table.How can I get the values (twice) from the right table?Thanks!
mfemenel
Professor Frink
1421 Posts
Posted - 2008-07-12 : 07:50:22
There must be a wrinkle to this that I'm missing. Are you saying you want only 1 place to return for both values in the right table? Or just do a straightforward return whatever matches in the right table. Example below if the latter is the case. Otherwise I need you more explanation. Maybe post what you want your result to look like.select l.CustomerId,r.Placefrom LeftTable Linner join RightTable r on l.CustomerPostalAddressZipCodeID=r.ZipCodeIDMike"oh, that monkey is going to pay"
Stig Christian Aske
Starting Member
6 Posts
Posted - 2008-07-12 : 08:00:51
Hi!I want the result to look like this:CustomerCompanyName CustomerVisitAddressZipCodeID Place CustomerPostalAddressZipCodeID Placeex. MixMedia INC, South Beach 1, Seattle, PO. Box 55, Los AngelesSo I want to do two queries from the right table for each record in the left table. First the VisitAddressZipCodeID, and then the PostalAddressZipCodeID