Simon Slavin ha scritto:
> On 22 Dec 2009, at 10:25am, Andrea Galeazzi wrote:
>
>   
>> ID INTEGER,
>> Name TEXT
>>
>> So, for instance, I can have:
>>
>> 1 Julia
>> 2 Eric
>> 3 Kevin
>> 4 Sarah
>> 5 John
>>
>> Now I wanna move Eric from 2 to 4 in order to yield (by performing a 
>> series of UPDATE of ID field):
>>
>> 1 Julia
>> 2 Kevin
>> 3 Sarah
>> 4 Eric
>> 5 John
>>
>> What's the correct sequence of SQL statements to accomplish a such kind 
>> of task?
>>     
>
> Something like
>
> UPDATE myTable SET id=id-1 WHERE id>oldplace AND id<=newplace
> UPDATE myTable SET id=newplace WHERE name='Eric'
>
> You will need to detect whether you're moving the single record up or down 
> and change the UPDATE accordingly (or you could use ABS but that would be 
> even more confusing).
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
> __________ Informazioni da ESET NOD32 Antivirus, versione del database delle 
> firme digitali 4708 (20091222) __________
>
> Il messaggio รจ stato controllato da ESET NOD32 Antivirus.
>
> www.nod32.it
>
>
>
>
>   
Probably it won't work because ID must be UNIQUE and Name is not.
Other ideas?
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to