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.
| Author |
Topic |
|
mickyjtwin
Starting Member
12 Posts |
Posted - 2007-03-18 : 21:13:34
|
| I 3 tables which hold locations, specialities and contacts.tblLocationsLocationIDTitletblSpecialitiesSpecialityIDTitletblContactContactIDNameLocationIDSpecialityIDI am working with a serach directory that has a dropdown list for specialities. When a user selects a speciality, the location dropdown will update with locations found, i.e. assigned to a contact.CREATE PROCEDURE sp_GetLocationsBySpecialityID@SpecialityID intASSELECT LocationID, Title FROM tblLocations ...Not sure how to implement this search!Thanks in advance,Mick |
|
|
mickyjtwin
Starting Member
12 Posts |
Posted - 2007-03-18 : 21:53:53
|
| I figured it out...SELECT LocationID, Title FROM tblLocationsWHERE LocationID IN (SELECT LocationID FROM tblContacts WHERE SpecialityID = @SpecialityID) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-18 : 21:59:22
|
or use INNER JOINselect l.LocationID, l.Titlefrom tblLocations linner join tblContacts con l.LocationID = c.LocationIDwhere c.SpecialityID = @SpecialityID KH |
 |
|
|
|
|
|