我在mySQL表上显示的图表为:
uidFrom, uidTo
1 4
4 1
1 5
5 1
6 1 <- only incoming edge
如何只获得“6,1”对,仅输入“1”?我的意思是,如何查询唯一的传入边缘到节点“1”(不是传入和传出,如4或5)?
提前致谢;
答案 0 :(得分:1)
你可以这样做:
SELECT uidFrom, uidTo
FROM Graph g
WHERE NOT EXISTS (
SELECT * FROM Graph rev WHERE rev.uidFrom=g.uidTo AND rev.uidTo=g.uidFrom
)