Re: [SQL] Sequential non unique IDs

2008-04-01 Thread Volkan YAZICI
On Tue, 1 Apr 2008, "John Reeve" <[EMAIL PROTECTED]> writes: > I have the following scenario: > > A 'task' table that has the fields: > id => primary key, updated on each insert using a sequence > customerid => integer > localid => integer > > I need the localid to be sequential an

Re: [SQL] Sequential non unique IDs

2008-04-01 Thread Craig Ringer
John Reeve wrote: > I've already considered: > 1. I can't lock the table, because there are too many inserts happening > and it will slow down the app. In a locking approach you may not need to lock the whole table. You should only need to lock the entry for the customer being altered, eg: BEGIN

[SQL] Sequential non unique IDs

2008-04-01 Thread John Reeve
I have the following scenario: A 'task' table that has the fields: id => primary key, updated on each insert using a sequence customerid => integer localid => integer I need the localid to be sequential and unique per unique customerid. The data needs to look like this: 1, 92, 1

Re: [SQL] difference between EXCEPT and NOT IN?

2008-04-01 Thread Raphael Bauduin
On Tue, Apr 1, 2008 at 6:04 PM, Stephan Szabo <[EMAIL PROTECTED]> wrote: > On Tue, 1 Apr 2008, Raphael Bauduin wrote: > > > The 2 following statements don't give the same result. I expected the > > second ti give the exact same result as the first one. > > If any entree_id can be NULL they aren'

Re: [SQL] difference between EXCEPT and NOT IN?

2008-04-01 Thread Stephan Szabo
On Tue, 1 Apr 2008, Raphael Bauduin wrote: > The 2 following statements don't give the same result. I expected the > second ti give the exact same result as the first one. If any entree_id can be NULL they aren't defined to give the same result. EXCEPT is defined in terms of duplicates based on

[SQL] difference between EXCEPT and NOT IN?

2008-04-01 Thread Raphael Bauduin
Hi, The 2 following statements don't give the same result. I expected the second ti give the exact same result as the first one. What am I missing? development=> SELECT id FROM entrees except select entree_id from postes ORDER BY id desc; id -- 3651 (1 row) development=> SELECT id FROM e