Re: [SQL] consistent random order

2006-11-29 Thread Michael Fuhr
On Wed, Nov 29, 2006 at 12:32:56PM -0500, Jeff Herrin wrote: > I don't think cursors are going to help in this case. The order > by random() is still going to give different result sets on different > pages. Have you tried using setseed() to seed the random number generator to the same value befor

Re: [SQL] SQL command join question

2006-11-29 Thread Tom Lane
"Ehab Galal" <[EMAIL PROTECTED]> writes: > SELECT t1.* > FROM (t1 outer join t2 on (t1.a=t2.a and t1.b=t2.b)) t outer join t3 on > (t1.c=t3.c); > ERROR: invalid reference to FROM-clause entry for table "t1" > HINT: There is an entry for table "t1", but it cannot be referenced from > this part

Re: [SQL] SQL command join question

2006-11-29 Thread Richard Broersma Jr
> SELECT t1.* > FROM (t1 outer join t2 on (t1.a=t2.a and t1.b=t2.b)) t outer join t3 on ^^ > (t1.c=t3.c); ^^ -- which one t or t1? > I'm getting the following error message: > ERROR: invalid reference to FROM-clause entry for table "t1"

Re: [SQL] SQL command join question

2006-11-29 Thread Stephan Szabo
On Wed, 29 Nov 2006, Ehab Galal wrote: > I have three tables t1(a, b, c, d), t2(a, b, c, k), and t3(c, e). I need to > outer join them as shown below, but only have all tuples from t1 as output. > But the following syntax does not allow me to do so. > > SELECT t1.* > FROM (t1 outer join t2 on (t1.

Re: [SQL] SQL command join question

2006-11-29 Thread Phillip Smith
Would this be more appropriate...? SELECT t1.* FROM t1 OUTER JOIN t2 ON (t1.a=t2.a AND t1.b=t2.b) OUTER JOIN t3 ON (t1.c=t3.c); -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ehab Galal Sent: Thursday, 30 November 2006 11:

[SQL] SQL command join question

2006-11-29 Thread Ehab Galal
Hi, I have three tables t1(a, b, c, d), t2(a, b, c, k), and t3(c, e). I need to outer join them as shown below, but only have all tuples from t1 as output. But the following syntax does not allow me to do so. SELECT t1.* FROM (t1 outer join t2 on (t1.a=t2.a and t1.b=t2.b)) t outer join t3 on

Re: [SQL] Subselects in CHECK clause ...

2006-11-29 Thread James Robinson
Gotcha. This is indeed to ensure a specialized ref integrity bit, against a column which "ought not ever change". Once some more old code goes away, then can fully normalize this area, making this check subselect bit go away, replaced by a regular FK. Hmm -- probably could even now make it

Re: [SQL] Subselects in CHECK clause ...

2006-11-29 Thread Stephan Szabo
On Wed, 29 Nov 2006, James Robinson wrote: > I see that subselects are not directly supported in check clauses, > but one can work around that by writing a stored function which > returns boolean and performs the subselect. Are there any known > gotchas with doing this? To completely get the con

Re: [SQL] consistent random order

2006-11-29 Thread Jeff Herrin
I don't think cursors are going to help in this case. The order by random() is still going to give different result sets on different pages. Jeff - Original Message - From: Andreas Kretschmer <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Sent: Wednesday, November 29, 2006 12:27:42 PM

Re: [SQL] consistent random order

2006-11-29 Thread Jeff Herrin
I need it a little more random than that. In both these scenarios, the same items will always follow each other. Jeff - Original Message - Why not create a random seed between 1 and the number of possibilities in your web application when a user first hits the site, store that in the

Re: [SQL] consistent random order

2006-11-29 Thread Andreas Kretschmer
Jeff Herrin <[EMAIL PROTECTED]> schrieb: > I am returning results ordered randomly using 'order by random()'. My issue > has > to do with page numbers in our web application. When I hit the 2nd page and > retrieve results with an offset, ordering by random() isn't really what I want > since I wil

[SQL] Subselects in CHECK clause ...

2006-11-29 Thread James Robinson
I see that subselects are not directly supported in check clauses, but one can work around that by writing a stored function which returns boolean and performs the subselect. Are there any known gotchas with doing this? The CREATE TABLE docs regarding CHECK clauses states: "Currently, CHE

Re: [SQL] consistent random order

2006-11-29 Thread Aaron Bono
On 11/29/06, Jeff Herrin <[EMAIL PROTECTED]> wrote: I am returning results ordered randomly using 'order by random()'. My issue has to do with page numbers in our web application. When I hit the 2nd page and retrieve results with an offset, ordering by random() isn't really what I want since I w

[SQL] consistent random order

2006-11-29 Thread Jeff Herrin
I am returning results ordered randomly using 'order by random()'. My issue has to do with page numbers in our web application. When I hit the 2nd page and retrieve results with an offset, ordering by random() isn't really what I want since I will often receive results that were on the 1st pag