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
 how to select with inner join

Author  Topic 

tpiazza55
Posting Yak Master

162 Posts

Posted - 2007-08-05 : 18:04:15
Hi:

I have a record that has location1, price1, location2, price2

How would I do an inner join or "how would I " get the name of the location?

location table -- locationid, locationname
producttable -- location1, location2 is the locationid in location table

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-08-05 : 18:12:29
[code]SELECT p.location1, l1.locationname, p.location2, l2.locationname
FROM product p
INNER JOIN location l1 ON p.location1 = l1.locationid
INNER JOIN location l2 ON p.location2 = l2.locationid[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -