Mysql 仅在第一组值上联接两个表

Mysql 仅在第一组值上联接两个表,mysql,join,Mysql,Join,“minValue”取决于源,而不是“destination” 我尝试的查询是: Table 1 : Anamoly id Source 1 dls 2 aus 3 dls 4 aus Table 2 : Logical_Mapping Source Destination minValue dls hst 1 aus hst 2 dls buf 1 a

“minValue”取决于源,而不是“destination”

我尝试的查询是:

Table 1 : Anamoly

    id Source
    1   dls
    2   aus
    3   dls
    4   aus
Table 2 : Logical_Mapping

Source Destination minValue
dls       hst         1
aus       hst         2
dls       buf         1
aus       buf         2

Expected Output
Anomaly-Mapping
id  Source Destination   minValue
1    dls    hst(or)buf      1
2    aus    hst(or)buf      2
3    dls    hst(or)buf      1
4    aus    hst(or)buf      2
这个问题似乎很有效。但我还需要“minValue”和“Destination”。

试试这个:

select an.id,an.Source, (select l.Destination from logical_mapping as l where an.Source= l.Source limit 1) as Dest from anomaly;

很抱歉,我没有清楚地解释我的输出。我的意思是像“hst”或“buf”。我还需要第一个表中的所有行,即使第二个表中没有相应的条目。
SELECT an.id, an.source, l.destination, l.minValue
FROM anamoly an
LEFT JOIN logical_mapping l ON l.source=an.source