I am trying to write a query that can get result from multiple tables:
Item Category
| ic_id | ic_name |
|---|---|
| 1 | PC |
| 2 | Laptop |
| 3 | Printer |
| 4 | Scanner |
Items
| i_id | i_category | i_name |
|---|---|---|
| 1 | 1 | Dell Optiplex |
| 2 | 2 | HP Probook 450 |
| 3 | 2 | HP Probook650 |
| 4 | 3 | HP Laserjet 402dn |
| 5 | 1 | Dell MT3030 |
Item Sale
| is_id | is_date | is_customer |
|---|---|---|
| 1 | 15-03-2021 | John |
| 2 | 16-03-2022 | Jimmy |
| 3 | 18-03-2023 | Mark |
Item Sale Detail
| isd_id | isd_sale_id | isd_item |
|---|---|---|
| 1 | 1 | 2 |
| 2 | 1 | 3 |
| 3 | 2 | 4 |
| 4 | 3 | 1 |
| 5 | 3 | 5 |
| 6 | 3 | 4 |
Is it possible to get combined result of GROUP CONCAT with COUNT in 1 query? Please guide me to write the query to get the desired result, I want the query result as shown below, Thanks:
Desired Result
| is_id | is_date | is_customer | items |
|---|---|---|---|
| 1 | 15-03-2021 | John | Laptop: 3 |
| 2 | 16-03-2022 | Jimmy | Printer: 1 |
| 3 | 18-03-2023 | Mark | PC:2 , Printer: 1 |