Query question

From: Björn Metzdorf <bm(at)turtle-entertainment(dot)de>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Query question
Date: 2002-11-28 13:59:19
Message-ID: 033001c296e6$58be5bb0$81c206d4@office.turtleentertainment.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I've got a query which I'd like to optimize (for using indizes):

This is a working version, but it does not do exactly what I want:

------ snip -------
SELECT m.*
FROM table1 m,
table2 ms,
table3 s,
table4 l,
table5 c
WHERE m.id = 262451
AND ms.value2 = m.id
AND l.id = m.value
AND s.id = ms.slot
AND c.id = s.contestant
ORDER BY m.date ASC
------ snap -------

This version should theoretically do what I want, but it does not work (it
gives "ERROR: Relation "s" does not exist"):

------ snip -------
SELECT m.*
FROM table1 m,
table2 ms,
table3 s,
table4 l
LEFT JOIN table5 c ON s.id = ms.slot
WHERE m.id = 262451
AND ms.value2 = m.id
AND l.id = m.value
AND c.id = s.contestant
ORDER BY m.date ASC
------ snap -------

Thanks for your help.

Regards,
Bjoern

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nigel J. Andrews 2002-11-28 14:11:26 Re: Query question
Previous Message SZUCS Gábor 2002-11-28 12:59:34 Re: Select nextval problem