Re: Help with sqlite?



Hi,

On 6/13/07, Виталий Ищенко <betalb gmail com> wrote:
 > I couldn't figure out how to do it with one select statement.

SELECT p.directory_path, p.name
FROM photos AS p
   INNER JOIN photo_tags AS pt ON pt.photo_id = p.id
   INNER JOIN tags       AS t  ON pt.tag_id   = t.id
WHERE t.id = 3;

t.id - it's id of your tag
This query is rather slow
Joins are resource hungry

Thanks much to you and Pasi for your solutions. The following seems to
work, too:

select photos.directory_path, photos.name from photos, photo_tags
where photo_tags.tag_id = 33 and photo_tags.photo_id = photos.id;

Best,

Todd


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]