所以,我有这个 MySQL 表。以下是相关列:
| raw line | composed_line | next_line
|----------------------|---------------|------------------------
| | | When I have a bad day,
| I cry my eyes out. | | When I cry my eyes out,
| I get ice cream. | | When I get ice cream,
| Things seem better. | | When things seem better,
| I get out of bed. | | When I get out bed,
我有这个查询,它可以做我想做的事情——它从倒数第二行的“下一行”列中选择数据,并将其与最近行的“raw_line”列中的数据结合起来。
SELECT CONCAT((SELECT `next_line` FROM `lines` ORDER BY id DESC LIMIT 1 OFFSET 1),
(SELECT `raw_line` FROM `lines` ORDER BY id DESC LIMIT 1))
所以结果看起来像
When things seem better, I get out of bed.
但是,我所有尝试获取此结果并将其插入最近一行的名为“composed_line”的列中都失败了。我曾尝试使用 PHP 和 SQL 来执行此操作,但都不起作用。
如果我能想出一种方法来显示(在 PHP 中)带有 'next_line' 和 'raw_line' 并按 ID asc 排序的 whoooole 表,我就不需要这样做,但我尝试这样做也有令人沮丧的失败,总是一起显示'next_line',然后一起显示'raw_lines',或者其他一些不需要的糟糕结果(doublesadface)。
我想要的结果如下:
When I have a bad day, I cry my eyes out.
When I cry my eyes out, I get ice cream.
When I get ice cream, things seem better.
When things seem better, I get out of bed.
我是 SQL 的新手。任何帮助将非常感激。