我有一个非常简单的表,其中包含ID Primary Key
,SITE_X
和SITE_Y
。例如,我要查询从site A
到site F
的路线,结果应该是这样的:
SELECT a.ID AS id1,b.ID AS id2,a.SITE_X, a.SITE_Y, b.SITE_X, b.SITE_Y
FROM GRAFO_TESTE.teste_1 a
JOIN GRAFO_TESTE.teste_1 b
ON a.SITE_Y = b.SITE_X
WHERE a.SITE_X = 'AA'
OR b.SITE_Y = 'FF';
ID SITE_X SITE_Y
1 AA BB
2 BB CC
3 DD EE
4 GG FF
5 GG HH
6 GG CC
7 EE FF
ROTA from site AA to site FF
SITE_X-Y
AA-BB
BB-CC
CC-DD
DD-FF
预期结果