Re: [SQL] Can I do this smarter?

2006-07-13 Thread Joost Kraaijeveld
Hi Aaron, On Thu, 2006-07-13 at 22:52 -0500, Aaron Bono wrote: > SELECT >invoices.objectid, >invoices.invoicenumber, >invoices.invoicedate, >salesorders.customer, >customers.customernumber, >customers.lastname > FROM invoices > INNER JOIN salesorders ON ( >salesorders.o

Re: [SQL] Can I do this smarter?

2006-07-13 Thread Aaron Bono
On 7/13/06, Joost Kraaijeveld <[EMAIL PROTECTED]> wrote: I have three tables: customers, salesorders and invoices. Customers havesalesorders and salesorders have invoices ( child tables have foreignkey columns to their parent).I want to get a list of all invoices with their customers. This what I c

[SQL] Can I do this smarter?

2006-07-13 Thread Joost Kraaijeveld
I have three tables: customers, salesorders and invoices. Customers have salesorders and salesorders have invoices ( child tables have foreign key columns to their parent). I want to get a list of all invoices with their customers. This what I came up with: select invoices.objectid, invoices.i

Re: [SQL] Trigger, record "old" is not assigned yet

2006-07-13 Thread Aaron Bono
On 7/13/06, Adrian Klaver <[EMAIL PROTECTED]> wrote: For plpgsql use TG_OP. See link below.http://www.postgresql.org/docs/8.1/interactive/plpgsql-trigger.htmlOn Thursday 13 July 2006 03:50 pm, Daniel Caune wrote: > Hi, I've created a trigger BEFORE INSERT OR UPDATE on a table and, indeed,> when

Re: [SQL] Trigger, record "old" is not assigned yet

2006-07-13 Thread Adrian Klaver
For plpgsql use TG_OP. See link below. http://www.postgresql.org/docs/8.1/interactive/plpgsql-trigger.html On Thursday 13 July 2006 03:50 pm, Daniel Caune wrote: > Hi, > > > > I've created a trigger BEFORE INSERT OR UPDATE on a table and, indeed, > when the trigger is raised before insertion the re

[SQL] Trigger, record "old" is not assigned yet

2006-07-13 Thread Daniel Caune
Hi,   I’ve created a trigger BEFORE INSERT OR UPDATE on a table and, indeed, when the trigger is raised before insertion the record “old” is not assigned.  Is there a way to distinguish in the trigger procedure from an insert statement to an update statement?   Regards,     -- Danie

Re: [SQL] How to find entries missing in 2nd table?

2006-07-13 Thread Richard Broersma Jr
> > > > SELECT controller_id FROM control > > > > WHERE controller_id NOT IN > > > > (SELECT DISTINCT controller_id FROM datapack); > > > The DISTINCT is not necessary. I have heard with Oracle that DISTINCT > > is a > > > huge performance problem. Is that true on PostgreSQL also? > > > > From my

Re: [SQL] How to find entries missing in 2nd table?

2006-07-13 Thread Aaron Bono
On 7/12/06, Exner, Peter <[EMAIL PROTECTED]> wrote: Hi,what aboutSELECT controller_id FROM controlWHERE controller_id NOT IN(SELECT DISTINCT controller_id FROM datapack);The DISTINCT is not necessary.  I have heard with Oracle that DISTINCT is a huge performance problem.  Is that true on PostgreSQL

Re: [SQL] How to find entries missing in 2nd table?

2006-07-13 Thread Aaron Bono
On 7/13/06, Richard Broersma Jr <[EMAIL PROTECTED]> wrote: > > SELECT controller_id FROM control> > WHERE controller_id NOT IN> > (SELECT DISTINCT controller_id FROM datapack);> The DISTINCT is not necessary.  I have heard with Oracle that DISTINCT is a > huge performance problem.  Is that true on

Re: [SQL] How to find entries missing in 2nd table?

2006-07-13 Thread Richard Broersma Jr
> > SELECT controller_id FROM control > > WHERE controller_id NOT IN > > (SELECT DISTINCT controller_id FROM datapack); > The DISTINCT is not necessary. I have heard with Oracle that DISTINCT is a > huge performance problem. Is that true on PostgreSQL also? >From my experience, it does not prefo