> sqlite>create table fruits (id int primary key, name varchar(50)); > sqlite>create table temp (id int primary key, type int, name varchar(50)); > sqlite>insert into temp values (1, 0, 'apple'); > sqlite>insert into temp values (2, 0, 'orange'); > sqlite>insert into temp values (3, 1, 'potato'); > sqlite>insert into temp values (4, 1, 'onion'); > sqlite>insert into temp values (5, 0, 'banana'); > sqlite>insert into fruits select ifnull((select max(id) from fruits), 0)+1, > name from temp where > type = 1; > Assertion failed!
This is a bug. It's fixed in CVS now. http://www.sqlite.org/cvstrac/chngview?cn=2227 > How could I query without error ? The statement: INSERT INTO fruits SELECT ifnull((SELECT max(id)+1 FROM fruits), 1), name FROM temp... gives the same results as what you have above (it is slower though). But I don't think that's what you want. Take a look at this: http://www.sqlite.org/faq.html#q1 If I guess correctly, you want to change the fruits table to: CREATE TABLE fruits(id INTEGER PRIMARY KEY, name VARCHAR(50); and the INSERT statement to: INSERT INTO fruits SELECT NULL, name FROM temp WHERE type = 1; __________________________________ Do you Yahoo!? The all-new My Yahoo! - What will yours do? http://my.yahoo.com