C1 | C2 | c1_y_id | c2_y_id
ID |值
c1_y_id和c2_y_id到tableY的外键。
这里如何获得c1值;
Select value From tableX, tableY Where tableX.c1_y_id = tableY.id
我只需要用一个sql获取c1和c2的值。感谢您的任何建议
答案 0 :(得分:0)
我认为以下SQL应该适用于您的目的
SELECT Y1.value AS c1_value
,Y2.value AS c2_value
FROM tableX X
INNER
JOIN tableY Y1
ON X.c1_y_id = Y1.id
INNER
JOIN tableY Y2
ON X.c2_y_id = Y2.id
希望这有帮助