Я хочу сравнить данные базы данных в php.
Это моя таблица
таблица hospital_payment_data
id | date | cash_amount_received
----------------------------------
1 2020-04-01 7000
2 2020-04-29 1000
3 2020-04-29 2000
4 2020-04-29 3000
5 2020-04-29 4000
6 2020-04-29 5000
7 2020-04-29 6000
8 2020-04-29 70000
cash_receipt_publi sh таблица
id | date | amount
----------------------------------
1 2020-04-29 1000
2 2020-04-29 2000
3 2020-04-29 3000
4 2020-04-29 4000
5 2020-04-29 5000
6 2020-04-29 5000
7 2020-04-29 7000
Это мой sql синтаксис
SELECT ifnull(hospital_payment_data.id,'-') AS pg_id,
ifnull(hospital_payment_data.date,'-') AS pg_date,
ifnull(hospital_payment_data.cash_amount_received,'-') AS pg_amount,
ifnull(cash_receipt_publish.id,'-') AS van_id,
ifnull(cash_receipt_publish.date,'-') AS van_date,
ifnull(cash_receipt_publish.amount,'-') AS van_amount
FROM hospital_payment_data
LEFT JOIN cash_receipt_publish ON hospital_payment_data.id = cash_receipt_publish.id
UNION ALL
SELECT ifnull(hospital_payment_data.id,'-') AS pg_id, ifnull(hospital_payment_data.date,'-') AS pg_date, ifnull(hospital_payment_data.cash_amount_received,'-') AS pg_amount,
ifnull(cash_receipt_publish.id,'-') AS van_id, ifnull(cash_receipt_publish.date,'-') AS van_date, ifnull(cash_receipt_publish.amount,'-') AS van_amount
FROM hospital_payment_data
RIGHT JOIN cash_receipt_publish ON hospital_payment_data.id = cash_receipt_publish.id
WHERE hospital_payment_data.id IS NULL limit 0
на этой странице:
I Требуемый результат
Если дата и сумма совпадают или сумма совпадает, я бы хотел express как Ложь, сравнив таблицу с таблицей в cash_receipt_publi c.
id | cash_amount_received | amount| result
-----------------------------------------------------
1 7000 7000 true
2 1000 1000 true
3 2000 2000 true
4 3000 3000 true
5 4000 4000 true
6 5000 5000 true
7 6000 null false
8 10000 null false
9 null 5000 false