Why do you use a subquery? it is clear that the field in the database has a value, but it is empty.

what is the cause of this situation, and how to solve
SELECT

o.order_id,
o.send_goods_status send_goods_status,

FROM

(
    SELECT
        o.order_id,
        mi.STATUS send_goods_status,
    FROM
        ypb_order_info o
    LEFT JOIN ypb_order_merchandiser_mission_info mi ON o.order_id = mi.order_id
    AND mi.create_time = (
        SELECT
            MAX(create_time)
        FROM
            ypb_order_merchandiser_mission_info
        GROUP BY
            id
        ORDER BY
            create_time DESC
        LIMIT 1
    )
) o

GROUP BY

o.order_id

ORDER BY

o.create_time DESC

send_goods_status is empty, but I checked that the table has data.
my goal is to find out that each order in the ypb_order_merchandiser_mission_info table corresponds to multiple items, but I only take the latest one

Mar.13,2021

post the SQL.

Menu