Ordering query result by field from a different table (MySQL)

后端 未结 2 476
伪装坚强ぢ
伪装坚强ぢ 2021-01-27 08:28

I have a MySQL table structure and need to get a specific query working but I just can\'t wrap my head around it somehow. First off, here\'s the relevant table structure.

<
2条回答
  •  一整个雨季
    2021-01-27 08:59

    If you would like to avoid duplicates, you can use group by on the date:

    SELECT f.id, STR_TO_DATE(w.werte, '%d.%m.%Y') as d 
     FROM folders f JOIN werte w
     ON w.folder_id = f.id
     GROUP BY d
     ORDER BY d;
    

提交回复
热议问题