Im trying to fetch data from 2 tables one is loan table and second is payment table from database and want to show in one customer table in html.
order based on name_id,month_id,session_id and date.
data display in html table is order by name_id,month_id,session_id and date form both tables from database.
loan
name_id | session_id | month_id | amount |date
1 | 02 | 01 | 100 |2020-01-13
2 | 03 | 02 | 20 |2020-01-15
1 | 02 | 01 | 400 |2020-01-12
2 | 03 | 01 | 300 |2020-01-13
Payment
name_id | session_id | month_id | amount | date
1 | 02 | 02 | 100 |2020-01-13
2 | 03 | 02 | 10 |2020-01-12
1 | 02 | 03 | 100 |2020-02-11
2 | 03 | 01 | 100 |2020-01-13
Just use UNION ALL :
(SELECT 'loan' as type, name_id, session_id, month_id, amount, date
FROM loan)
UNION ALL
(SELECT 'payment' as type, name_id, session_id, month_id, amount, date
FROM payment)
ORDER BY name_id, month_id, session_id, date
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.