Let's imagine following situation:
CREATE TABLE test (id int4 PRIMARY KEY, priority int4); INSERT INTO test (id) SELECT DISTINCT (random() * 100000000)::int4 FROM generate_series(1,1000);
Table test will now contain some (up to 1000) records, with random ids.
Now, we want to update first 3 records (ordered by id) to have following values in priority:
- 10000
- 5000
- 1000
Continue reading Tips N’ Tricks – setting field based on order