2018-01-22 22:36 GMT+01:00 Jim Morris <[email protected]>:

> Wouldn't the mod operator do this?
>
> Do an update and set key = 1 + (5 + key)%5


​Only when the values are: 1.0, 2.0, 3.0, 4.0 and 5.0.
But not when they are: 1.25, 1.5, 1.75, 2.0 and 1.0.


On 1/22/2018 12:38 PM, David Raymond wrote:
>
>> Unless I'm reading you wrong then just do the normal
>>
>> begin transaction;
>> update playYouTubeVideo set speed = (
>>      select speed from playYouTubeVideo where key = '2')
>>      where key = '1';
>> update playYouTubeVideo set speed = (
>>      select speed from playYouTubeVideo where key = '3')
>>      where key = '2';
>> ...
>> update playYouTubeVideo set speed = (
>>      select speed from playYouTubeVideo where key = '5')
>>      where key = '1';
>> commit;
>>
>>
>> -----Original Message-----
>> From: sqlite-users [mailto:[email protected]]
>> On Behalf Of Cecil Westerhof
>> Sent: Monday, January 22, 2018 3:30 PM
>> To: SQLite mailing list
>> Subject: [sqlite] Can this be done with SQLite
>>
>> I have the following table:
>> CREATE TABLE playYouTubeVideo (
>>      key     TEXT    NOT NULL,
>>      speed   FLOAT   NOT NULL,
>>
>>      CONSTRAINT key   CHECK(length(key)  == 1),
>>      CONSTRAINT speed CHECK(TYPEOF(speed) = "real"),
>>
>>      PRIMARY KEY(key)
>> );
>>
>>
>> Say I want to rotate a part:
>> - The value by key '1' becomes the value by key '2'.
>> ​- The value by key '2' becomes the value by key '3'.
>> ​- The value by key '3' becomes the value by key '4'.
>> - The value by key '4' becomes the value by key '5'.
>> - The value by key '5' becomes the value by key '6'.
>>
>> ​I suppose that I need to do this programmatically, or can this be done
>> with SQL?
>>
>> And optionally also:
>> ​- The value by key '1' becomes the value by key '5'.
>> ​
>>
>
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
Cecil Westerhof
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to