Hi, thanks this is great.  Of course I forgot to mention that the id  
is a primary key, so I get an error about duplicate primary keys.

I tried this:

update binary_report_fmt set column_id = column_id + 1 where column_id  
= (select column_id from binary_report_fmt where column_id >= 3 order  
by column_id desc);

but it only updates the last item.   I guess I can make it a non- 
primary key..then it works perfectly.

Gregor

On 16-Jun-08, at 10:04 AM  , [EMAIL PROTECTED] wrote:

> update
> table
> set id = id + 1
> WHERE
> id > 1
>
> RBS
>
>
>> Sorry about this, but this is a SQL question and not a SQLite  
>> specific
>> question.
>>
>> Is there a way to increment a value in a table in-situ.   Without
>> reading it, incrementing it, writing it?
>>
>> I need to insert an entry into a table, it has an id, all entries  
>> with
>> id's >= the id need to be incremented to keep the id's unique
>>
>> ie
>>
>> 1 bob
>> 2 joe
>> 3 irene
>>
>> someone wants to insert 2 sarah, I need the table to look like this
>>
>> 1 bob
>> 2 sarah
>> 3 joe
>> 4 irene
>>
>>
>> Any help would be great.
>> thanks
>>
>> -----------------------------------------------------------------
>> Gregor
>>
>>
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>>
>
>
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to