我有两个问题给了我想要的结果。有没有机会把它们合二为一。查询如下:第一个查询如下:
SELECT c.cy_id, c.to_id AS TSN </跨度> , se.x AS tX, se.y AS ty来自cJOIN se ON c.to_id = se.ar联盟SELECT c.cy_id, c.to_id AS TSN </跨度> , swt.x AS tx, swt.y ASTY来自cJOIN swt ON c.to_id = swt.ar
第二个
SELECT c.cy_id, c.to_id AS tsn, se.x AS tX, se.y AS ty, c.fr_id AS fsn, sef.x AS fX, sef.y AS fy FROM c JOIN se ON c.to_id = se.ar JOIN se as sef ON c.fr_id = sef.ar UNION -- UNION ALL may be better SELECT c.cy_id, c.to_id, swt.x, swt.y, null, null, null FROM c JOIN swt ON c.to_id = swt.ar
的 你应该试试这个: http://sqlfiddle.com/#!2/1b660/3 强> <强/>
SELECT A.cy_id, A.to_id AS tsn, B.x AS tX, B.y AS ty, C.x AS tx, C.y AS tY, A.fr_id AS fsn, BB.x AS fX, BB.y AS fy FROM c A JOIN se AS B ON A.to_id = B.ar JOIN swt C ON A.to_id = C.ar JOIN se BB ON A.fr_id = BB.ar;