This question reflects my issue. How to do this in SQLite?
I’ve tried UPDATE with self-joins, isolating the self join in sub-query, triggers, and something similar to this. Here is an example:
UPDATE stage
SET title =
(
SELECT
prior.title
FROM
stage prior,
stage now
WHERE
prior.rownum+1 = now.rownum
)
WHERE
title is null
Every table in SQLite has got a pseudo-column called rowid (which can be accessible under several different names:
rowid,oid,_rowid_, unless those names are assigned to other, real, columns). The rowid column is essentially a unique row identifier and you can use it as a sort criterion and/or in conditions.The following query demonstrates how your problem can be solved with the help of rowid:
Here’s a demo on SQL Fiddle.
You can read more about rowid in this SQLite manual.