List:General Discussion« Previous MessageNext Message »
From:Mike Martin Date:January 11 2006 9:23pm
Subject:Re: Help crafting an SELECT
View as plain text  
On 1/11/06, Gordon Bruce <gordon@stripped> wrote:
> I assume you are looking for both red and car.
> You can not use IN because that is implicitly an IN.
> You hae to join the tags table to itself using 2 different aliasis.
> {If you required 3 things then you would join it 3 times etc..}
>
> SELECT *
> FROM   pics
>        INNER JOIN tags AS t1
>        ON (pics.picid=t1.picid
>            AND t1.tag = 'Car'
>            )
>        INNER JOIN tags AS t2
>        ON (pics.picid=t2.picid
>            AND t2.tag = 'Red'
>            )
>

Brilliant!

Not only does it work but I can easily piece it together for multiple tags.

Thanks!
MikeMartin
Thread
Help crafting an SELECTMike Martin11 Jan
  • Re: Help crafting an SELECTSGreen11 Jan
  • Re: Help crafting an SELECTPeter Brawley11 Jan
Re: Help crafting an SELECTMike Martin11 Jan
Re: Help crafting an SELECTSGreen11 Jan