HI all,
I have two tables, let's say AudioTrack and Category
Every AudioTrack record can belong to one or more ( or none )
Categories.
I have created an intermediate table, AudioTracks_ Categories
containing only the IDs of AudioTrack and Category to keep track of the
link.
I can easily find AudioTrack records for a given Category id:
select AudioTrack.* from AudioTrack left join AudioTracks_ Categories
on AudioTrack.AudioTrack_id = AudioTracks_ Categories.AudioTrack_id
where AudioTracks_ Categories.Category_id = somevalue
I can also easily find AudioTrack records for a given Category id OR
others Category id, adding distinct to avoid row duplication for
AudioTrack records contained in more than one of the specyfied
categories:
select distinct AudioTrack.* from AudioTrack left join AudioTracks_
Categories on AudioTrack.AudioTrack_id = AudioTracks_
Categories.AudioTrack_id where AudioTracks_ Categories.Category_id =
somevalue or AudioTracks_ Categories.Category_id = somevalue...
Now the question is, how can I handle an AND query, I mean how can I
have returned only the AudioTrack records that belongs to ALL the
Category IDs I put in the query?
Hope the question was clear... :)
thanks in advance for your answer,
Giulio
- Re: Join sintax question Giulio
- Re: Join sintax question Douglas Sims
- Re: Join sintax question Giulio
- Re: Join sintax question Michael Stassen