mysql get data from 2 tables using case

mysql get data from 2 tables using case

I have weeklydata and dailydata. I want to get the required output as give below. I need help in getting that

I have weeklydata and dailydata. I want to get the required output as give below. I need help in getting that

weeklydata

+---------+------------+------------+--------+------------+
| userid  | startdate  | enddate    | weekno |runningcost |
+---------+------------+------------+--------+------------+
| 10      | 2017-03-20 | 2017-03-26 | 12     | 200        |
| 10      | 2017-03-27 | 2017-04-02 | 13     | 300        |
| 10      | 2017-04-03 | 2017-04-09 | 14     | 200        |
+---------+------------+------------+--------+------------+

dailydata

+------------+-------+---------+
| startdate  | hours | userid  |
+------------+-------+---------+
| 2017-03-20 | 1    | 10      |
| 2017-03-21 | 1    | 10      |
| 2017-03-22 | 1    | 10      |
| 2017-03-23 | 1    | 10      |
| 2017-03-24 | 1    | 10      |
| 2017-03-25 | 1    | 10      |
| 2017-03-26 | 1    | 10      |
| 2017-03-27 | 2    | 10      |
| 2017-03-28 | 2    | 10      |
| 2017-03-29 | 2    | 10      |
| 2017-03-30 | 2    | 10      |
| 2017-03-31 | 2    | 10      |
| 2017-04-01 | 2    | 10      |
| 2017-04-02 | 2    | 10      |
+----+-------+-------+---------+

Output

+---------+------------+-------+-------+-------+-------+-------+-------+-------+
| userid  | startdate  | day1  | day2  | day3  | day4  | day5  | day6  | day7  |
+---------+------------+-------+-------+-------+-------+-------+-------+-------+
| 10      | 2017-03-20 | 1     | 1     | 1     | 1     | 1     | 1     | 1     |
| 10      | 2017-03-27 | 2     | 2     | 2     | 2     | 2     | 2     | 2     |
+---------+------------+-------+-------+-------+-------+-------+-------+-------+


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

MySQL Tutorial - Learn MySQL from Scratch

Complete MySQL Course: Beginner to Advanced. MySQL Tutorial - Learn MySQL from scratch and go from beginner to advanced in MySQL.

MySQL Tutorial: A Beginners Guide To Learn MySQL

MySQL Tutorial: A Beginners Guide To Learn MySQL - Let's take a look at a very in-depth MySQL tutorial that explores all the operations and commands that you need to explore your databases...

MySQL Tutorial for Beginners - MySQL Full Course

Learn MySQL for web development. This MySQL tutorial for beginners is a great way to learn SQL basics. What is SQL? SQL, short for Structured Query Language, is a language used by software developers, data scientists and anyone who works with data. In this course, we'll be using MySQL to learn SQL. MySQL is the most popular free and open-source database management system in the world. If you use a different DBMS (eg SQL Server), you can still benefit from this course as 90% of the skills you'll learn in this course can be transferred to other database management systems.