我有一个看起来像这样的表。
|path_id | 步骤 | point_id | delay_time | stand_time | 访问 |
| 202 | 1 | 111 | 0 | 0 | 7 |
按步骤顺序列出point_id。例如:111 - 步骤 1,181 - 步骤 2,等等。
我需要编写一个需要point_id的查询,选择在所有具有给定值的path_id中具有较高步长的所有值,并返回一组分组的point_id。
我目前正在使用此查询
SELECT DISTINCT `pdb`.`point_id` AS `id`
FROM `path_detail` AS `pda` INNER JOIN
`path_detail` AS `pdb` ON pda.path_id = pdb.path_id
AND pda.step < pdb.step
WHERE
(pda.point_id = 111)
GROUP BY `pdb`.`path_id`
这似乎不太可靠。
有什么建议吗?
尝试:
SELECT Distinct `pdb`.`point_id` AS `id`
FROM `path_detail` AS `pda`, `path_detail` AS `pdb`
WHERE
pda.point_id = 111
AND pda.path_id = pdb.path_id
AND pda.step < pdb.step
Order by `pdb`.`point_id` ASC