我有2张桌子
--------------------------------------------
TABLE 1:
ID
DUREE_FREQ_ID => foreign key idFrequence
POSOL_FREQ_ID => foreign key idFrequence
INTER
------------------------------------------
TABLE 2:
idFrequence
libFrequence
-------------------------------------------
我想进行查询以同时获取libFrequence
和DUREE_FREQ_ID
的{{1}}!
答案 0 :(得分:1)
SELECT Table1.*, t2a.libFrequence AS DUREElib, t2b.libFrequence AS POSOLlib
FROM Table1
INNER JOIN Table2 AS t2a ON Table1.DUREE_FREQ_ID = t2a.idFrequence
INNER JOIN Table2 AS t2b ON Table1.POSOL_FREQ_ID = t2b.idFrequence
答案 1 :(得分:0)
SELECT
t1.id,
t1.duree_freq_id,
td.libfrequence AS duree_freq,
t1.posol_freq_id,
tp.libfrequence AS posol_freq
FROM table1 t1
LEFT JOIN table2 td ON (td.idfrequence = t1.duree_freq_id)
LEFT JOIN table2 tp ON (tp.idfrequence = t1.posol_freq_id);