March 18, 2007 at 7:20 pm
I 3 tables which hold locations, specialities and contacts.
tblLocations
LocationID
Title
tblSpecialities
SpecialityID
Title
tblContact
ContactID
Name
LocationID
SpecialityID
I 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 int
AS
SELECT LocationID, Title FROM tblLocations
...
Not sure how to implement this search!
Thanks in advance,
Mick
March 18, 2007 at 7:46 pm
Try the following...
SELECT l.LocationID, l.Title FROM tblLocations l
join tblContact c on l.LocationId = c.LocationId
join tblSpecialities s on s.SpecialityId = c.SpecialityId
where s.SpecialityID = @SpecialityID
MohammedU
Microsoft SQL Server MVP
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply