Subject Re: [Firebird-Architect] the insert into t select * from t infinite
Author Ann W. Harrison
Arno Brinkman wrote:
>
>>delete from t t1
>> where t1.id in (select first 5 t t2
>> from t order by t2.id);
>
> What is the list of 5?

Sorry, that was a typo. Here's a working version.

SQL> select count (*) from t;

COUNT
============

50

SQL> delete from t t1 where t1.id in
CON> (select first 5 t2.id from t t2 order by t2.id);
SQL> select count (*) from t;

COUNT
============

0


In our current mode, executing that statement will delete at least 5 and
possibly all rows in the table, depending on the order in which they
were stored relative to the ascending order of id. I stored my data in
ascending order of t1, so everything went.

Here's a SQL standard version of the same problem:

SQL> select count (*) from t;

COUNT
============

50

SQL> delete from t t1 where t1.id in
CON> (select min(t2.id) from t t2);
SQL> select count (*) from t;

COUNT
============

0


Regards,


Ann