Answer the question
In order to leave comments, you need to log in
How to get rid of duplicate records when join?
There is an order table.
There is a timeline (there is fk - order_id).
SELECT o.id,
o.status,
order_payment_at,
order_cancel_at,
....
FROM orders AS o
INNER JOIN partners p ON p.id = o.partner_id
....
INNER JOIN(
SELECT
DISTINCT order_id,
CASE WHEN data LIKE '%{"status":"paid"}%' THEN created_at END AS order_payment_at,
CASE WHEN data LIKE '%{"status":"cancel"}%' THEN created_at END AS order_cancel_at
....
FROM timeline
) timeline ON timeline.order_id = o.id
GROUP BY o.id and long list.......
Answer the question
In order to leave comments, you need to log in
the request correctly displays everything, but it is necessary that ALL data from the timeline be in ONE line.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question