Unabashed wrote:
> I need to execute query
> SELECT wordForm FROM Lang.wform WHERE (ancode='someAncode') AND (wordNorm IN
> (SELECT DISTINCT id_norminrel FROM mgWordsRelations WHERE id_norm IN (SELECT
> wordNorm FROM Lang.wform WHERE wordForm='someWord'))) ORDER BY RANDOM()
> LIMIT 1

Try this:

select wf1.wordForm
from wform wf1 join mgWordsRelations rel on (wf1.wordNorm = rel.id_norminrel)
    join wform wf2 on (rel.id_norm = wf2.wordNorm)
where wf1.ancode = 'someAncode' and wf2.wordForm = 'someWord'
order by random() limit 1;

It's the same query, just written in a simpler form that might make it easier 
for SQLite to optimize.

Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to