[SQL] Need help in composing PostgreSQL query

2001-09-03 Thread Vladimir V. Zolotych
Hi Please help me compose the query in PostgreSQL. Using PostgreSQL 7.1.2. Suppose relations A and B have columns: {X1, X2, ..., Xm, Y1, Y2, ..., Yn} and {Y1, Y2, ..., Yn} Attributes Y1, Y2, ..., Yn are common for both relations and have the same type in both. How can I define in PostgreSQL

Re: [SQL] 2 tables, joins and same name...

2001-09-03 Thread Josh Berkus
Ross, > I haven't seen _any_ of these books for over a year, and know a lot > more > SQL than I did then, so take any recommendations with a grain of > salt. Hmmm... both of these books get good reviews. Is there anywhere (say, techdocs) where we could add a book list? I'll ask ... -Josh __

Re: [SQL] More on the TO DO wishlist

2001-09-03 Thread Josh Berkus
Peter, > > Given that Emacs has editing modes of varying sophistication for > most/all > of these languages, and XEmacs has a built-in PostgreSQL client > module, > one could write a minor mode for PG procedural languages that > quote-escape > the buffer and load it into the server. You hea

Re: [SQL] Index Scan Backward vs. Sort/Sequential Scan when using ORDER BY

2001-09-03 Thread Tom Lane
Keith Bussey <[EMAIL PROTECTED]> writes: > In trying to figure out just why my ORDER BY queries were so slow, I came > across something interesting. The issue here seems to be that Postgres is drastically underestimating the number of rows that will come out of the indexscan in the second case:

Re: [SQL] On Differing Optimizer Choices ( Again)

2001-09-03 Thread Tom Lane
Mark kirkwood <[EMAIL PROTECTED]> writes (heavily edited): > SELECT > ... > WHERE d0.d0key = f.d0key > AND f.d0key BETWEEN 270 AND 350 > So far this is all as one would expect. However suppose we substitute > 'd0.d0key' in the 'AND' clause instead of 'f.d0key' to obtain : > SELECT > ... > WHE

Re: [SQL] More on the TO DO wishlist

2001-09-03 Thread Peter Eisentraut
Josh Berkus writes: > Actually, I think this would be a role better served by an IDE. I've > long thought that it would be teriffic if someone wrote a PL/whatever > IDE (covering PL/pgSQL, PL/sh, PLtcl and PLperl). Given that Emacs has editing modes of varying sophistication for most/all of

Re: [SQL] More on the TO DO wishlist

2001-09-03 Thread Josh Berkus
Chris, > Can the parser be changed to be a little more intelligent about it's > error > reporting, This is on everybody's "todo" list. According to Bruce and Jan at LWE, though, better error reporting is not an easy fix. > and can it be changed to check if all variables, records, > etc. > hav

Re: [SQL] INSERT Syntax

2001-09-03 Thread Josh Berkus
Joseph, > insert into table1(field1,field2) values (select field1, field2 from > table > 2); Actually, that won't work in SQL Server either. The correct syntax (for both databases) is: INSERT INTO table1 ( field1, field2 ) SELECT field1, field2 FROM table2; The "VALUES" syntax is only appropr

Re: [SQL]

2001-09-03 Thread Stephan Szabo
On Mon, 3 Sep 2001, Joseph Syjuco wrote: > im new in postgresql (actually came from SQL Server) and i was trying a > script like this > > insert into table1(field1,field2) values (select field1, field2 from table > 2); > > i dont know if this is possible (inserting a set of entries via results

Re: [SQL]

2001-09-03 Thread Michael Davis
Try: Create table table1(field1,field2) as (select field1, field2 from table2); -Original Message- From: Joseph Syjuco [SMTP:[EMAIL PROTECTED]] Sent: Monday, September 03, 2001 3:03 AM To: [EMAIL PROTECTED] Subject: im new in postgresql (actually came from SQL Server) an

Re: [SQL]

2001-09-03 Thread Peter Eisentraut
Joseph Syjuco writes: > im new in postgresql (actually came from SQL Server) and i was trying a > script like this > > insert into table1(field1,field2) values (select field1, field2 from table > 2); The correct syntax is: INSERT INTO table1 (field1, field2) SELECT field1, field2 FROM table2;

[SQL] More on the TO DO wishlist

2001-09-03 Thread Chris Ruprecht
I did some pl/pgsql this morning and forgot a ';' at the end of a line. The result was, that the compiler complained about a wrong statement in line 304 - which is at the end of the program. The other error I made was that I used a new record without defining the record first. This, the program on

[SQL] GRANT ALL ON TO GROUP failure

2001-09-03 Thread Jari Aalto
Can anyone suggest, what is wrong with the following sql file? SOmehow the semicolon causes error? Jari class=# \i pg-def-group-grant.sql Granting ALL to ROOT CHANGE Granting ALL to USER psql:pg-def-group-grant.sql:48: ERROR: parser: parse error at or near "user" Granting SELECT t

Re: [SQL]

2001-09-03 Thread Joe Conway
> im new in postgresql (actually came from SQL Server) and i was trying a > script like this > > insert into table1(field1,field2) values (select field1, field2 from table > 2); > > i dont know if this is possible (inserting a set of entries via resultset > from a select stmt in one command). If

[SQL] duplicated oid

2001-09-03 Thread Carolyn Lu Wong
i'm using V6.5. >From my understanding, the oid should be unique in all rows of database. However, I'm getting duplicated data on one particular table, including the oid is the same! I don't recall trying to restore nor import any data. Any idea why? ---(end of broadcast

[SQL]

2001-09-03 Thread Joseph Syjuco
im new in postgresql (actually came from SQL Server) and i was trying a script like this insert into table1(field1,field2) values (select field1, field2 from table 2); i dont know if this is possible (inserting a set of entries via resultset from a select stmt in one command). If anyone has any