基于不同值的MySQL左联接匹配

问题描述 投票:0回答:1

我希望根据日期将两个表合并在一起。其中一个表中的日期值可以多次出现,但是我需要根据日期的唯一实例进行匹配。这是我无法使用的内容:

select idt.Incident_DateCopy, wt.weather_main
 from incidentdatatwo as idt left join weather as wt on 
     (select distinct(Incident_DateCopy) from incidentdata) as idate = wt.dt_iso

...

mysql
1个回答
0
投票

尝试一下

如果不起作用,请向您发送表模式

SELECT idt.Incident_DateCopy, wt.weather_main , 
(SELECT DISTINCT(Incident_DateCopy) FROM incidentdata) AS idate 
 FROM incidentdatatwo AS idt LEFT JOIN weather AS wt ON
HAVING idate = wt.dt_iso
© www.soinside.com 2019 - 2024. All rights reserved.