Yes, I forgot to add "at.name as AnimalType" in the select.

It's not a real-life sample, it was just a way to try to describe what
I am thinking about...

But I guess the answer is that only the "where" parts should be
indexed, not the id's in the joins?

/Jonas

On Thu, Nov 26, 2009 at 3:38 PM, Igor Tandetnik <itandet...@mvps.org> wrote:
> Jonas Sandman wrote:
>> If you have a join in an SQL-query, how do you add the statements to
>> optimize the query in an index?
>>
>> For example:
>>
>> select a.* from animals a
>> join animaltype at on at.id=a.typeid
>> where a.name='Monkey' and a.subspecies=2
>
> Why are you joining with animaltype here? You don't seem to use it for 
> anything.
>
> Igor Tandetnik
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to