我有一张table,上面有类似的行
+-----+-------+---------------+
| id | time | linked init id|
+-----+-------+---------------+
| 1 + 10.00 | 0 |
+-----+-------+---------------+
| 2 + 11.00 | 0 |
+-----+-------+---------------+
| 3 + 15.00 | 1 |
+-----+-------+---------------+
| 4 + 10.00 | 0 |
+-----+-------+---------------+
| 5 + 15.30 | 2 |
+-----+-------+---------------+
我想根据与“id”匹配的“linked init id”查询并排显示时间字段
例句:结果应该是这样的
+-----+-------+-------+
| id | time1 | time2 |
+-----+-------+-------+
| 1 | 10.00 | 15.00 | //because id value "1" = linked init id value "1"
+-----+-------+-------+
| 2 | 11.00 | 15.00 | //because id value "2" = linked init id value "2"
+-----+-------+-------+
我该怎么做?
注意:每个id只能有0或1个链接id行
2条答案
按热度按时间hvvq6cgz1#
您需要将表与其自身连接起来:
djmepvbi2#
你可以试试下面这个脚本-
此处演示