簡體   English   中英

MySQL基於不同值的左連接匹配

[英]MySQL left join match based on distinct values

我希望根據日期連接兩個表。 其中一個表中的日期值可以多次出現,但我需要基於日期的唯一實例進行匹配。 這是我所擁有的不起作用的東西:

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

...

嘗試這個

如果不起作用,請向您發送表架構

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM