![](/img/trans.png)
[英]mysql joins with one to many, many to one relations and no redundant data
[英]one to many relations data fetch from database mysql
試試這個:
set @start_date='2022-12-30';
set @end_date='2022-12-31';
WITH recursive Date_Ranges AS (
select @start_date as date
union all
select date + interval 1 day from Date_Ranges
where date < @end_date
)
SELECT
new_table.*,
(
SELECT
group_concat(`time`)
FROM
`clockin`
WHERE
`emid`=new_table.`id` AND
`date`=new_table.`date`
) as `time`
FROM
(select * from `user` full join Date_Ranges) as new_table
order by date desc
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.