You need to use a temporary table because by the time you select the key 1 
value it has already been overwritten.

BEGIN;
CREATE TEMP TABLE new_speed AS SELECT (key +4) % 5 AS key, speed FROM 
playYouTubeVideo;
UPDATE playYouTubeVideo SET speed = SELECT speed FROM new_speed WHERE 
new_speed.key = playYouTubeVideo.key;
DROP TABLE new_speed;
COMMIT;

-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von Cecil Westerhof
Gesendet: Montag, 22. Jänner 2018 23:12
An: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
Betreff: [EXTERNAL] Re: [sqlite] Can this be done with SQLite

2018-01-22 23:07 GMT+01:00 Igor Tandetnik <i...@tandetnik.org>:

> On 1/22/2018 4:36 PM, Cecil Westerhof wrote:
>
>>
>> When I do this, I get:
>> sqlite> SELECT *
>>     ...> FROM   playYouTubeVideo
>>     ...> WHERE  key BETWEEN '1' AND '5'
>>     ...> ;
>> 1|1.0
>> 2|2.0
>> 3|3.0
>> 4|4.0
>> 5|5.0
>>
>> [snip]
>>
>> sqlite> SELECT *
>>     ...> FROM   playYouTubeVideo
>>     ...> WHERE  key BETWEEN '1' AND '5'
>>     ...> ;
>> 1|2.0
>> 2|3.0
>> 3|4.0
>> 4|5.0
>> 5|2.0
>>
>> But I want the last one needs to be 1.0.
>>
>
> Something along these lines, perhaps:
>
> update playYouTubeVideo set key=char(61440+unicode(key)); update
> playYouTubeVideo set key=case when key=char(61440+unicode('1')) then
> '5' else char(unicode(key)-61440-1) end;
>

​This also expects the values to be constant. But what I want is that the 
record with key 1 gets the value from key 2, with key 2 from key 3, …

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


___________________________________________
 Gunter Hick | Software Engineer | Scientific Games International GmbH | 
Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 
1 80100 - 0

May be privileged. May be confidential. Please delete if not the addressee.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to