|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Reading Multiple Values from a Table
I am working in SQL Server, so I think I am in the right place! My question is, I have a table that is called CustomSearchListBox. Bascially, it is a table that converts that various abbreviations that I use into their full names. Such as city and county.
Here is what I have for a query SELECT Prp.IdNum, CustomSearchListBox.Label As City FROM Prp INNER JOIN CustomSearchListBox ON Prp.City = CustomSearchListBox.[Value] WHERE prp.IdNum = 123456 AND CustomSearchListBox.FieldName= 'City' This will return the item number and the name of the city(instead of the two letter abbrevation in the prp table) that the item is in. But now I also need to return the county the item is in too. How would I do the FROM part and WHERE part of the SQL statement. I tried just adding a CustomSearchListBox.Label As County and then added another INNER JOIN AND WHERE statement but I get an error saying Tables or functions 'CustomSearchListBox' and 'CustomSearchListBox' have the same exposed names. Use correlation names to distinguish them. Thanks in advanced! |
|
#2
|
|||
|
|||
|
what table is the 'County' field in??
|
|
#3
|
||||
|
||||
|
Code:
select Prp.IdNum
, CityBox.Label as City
, CountyBox.Label as County
from Prp
inner
join CustomSearchListBox as CityBox
on Prp.City
= CityBox.[Value]
and CityBox.FieldName= 'City'
inner
join CustomSearchListBox as CountyBox
on Prp.City
= CountyBox.[Value]
and CountyBox.FieldName= 'County'
where prp.IdNum = 123456
notice the correlation names CityBox and CountyBox to distinguish the two "copies" of the table |
|
#4
|
|||
|
|||
|
THANK YOU so much!! Your solution worked great!!! Thanks for the help and the quick response!!
|
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Reading Multiple Values from a Table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|