Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distinct on joined table

Status
Not open for further replies.

AndyApp

Programmer
Dec 20, 2001
259
GB
Hi,

I've got this SQL query (in access at the mo but will be going to .NET)

SELECT DISTINCT lkp_Band.BandName, Person.PersonName
FROM (lkp_Band INNER JOIN [Band] ON lkp_Band.ID = [Band].lkpBandID) INNER JOIN Person ON [Band].PersonID = Person.ID WHERE lkp_Band.ID LIKE -VARIABLE-;

Now I know DISTINCT doesn't work when you have a join but I need something similar. Basically it's a form of search so if someone searches for a person it will return a person but also return whichever band they've been in. And if someone searches for a band it returns the band but also all people in the band.

Both tables can have multiples in the other which is why there is a kind of lookup table in the middle (Band) which is where the multiples are stored. If that makes sense??

"Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway" - Jim Davis (Garfield)
 
This is the SQL Server group, not the Access group.

Access has completely different ansi(sql)compliance levels and syntax than SQL server. Any help here is unlikley to help you:(

Rob


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top