Query question - Mailing list pgsql-general

From Björn Metzdorf
Subject Query question
Date
Msg-id 033001c296e6$58be5bb0$81c206d4@office.turtleentertainment.de
Whole thread Raw
Responses Re: Query question  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
List 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


pgsql-general by date:

Previous
From: SZUCS Gábor
Date:
Subject: Re: Select nextval problem
Next
From: snpe
Date:
Subject: Re: Two features left - add