we have three tables
1. customer
2. custumerorder
3. order_type
customer: custumer_id , custumer_name, custumer_address,custumer_phone,status
Order_type order_type_id,orderType,
custumerorder custumerorder_id,custumer_id,order_type_id ,order_date,Total_order,shipping_info
i want to trace out the last order details so i have query
SELECT c.*,
tblcusorder.order_dt,
tblcusorder.orderType,
tblcusorder.shipping_info
FROM customer c
LEFT JOIN
( SELECT max(cr.order_date) AS order_dt,
ot.orderType,
cr.custumer_id,
cr.custumerorder_id,
cr.order_type_id,
cr.shipping_info
FROM custumerorder cr
INNER JOIN order_type ot ON ot.order_type_id=cr.order_type_id
GROUP BY cr.custumer_id ) AS tblcusorder ON tblcusorder.custumer_id=c.custumer_id
WHERE c.status='TRUE'
Issue
as I am using Max() function on order date so its showing last order date which is ok, but rest of row data is not from that row (customer order) and ordertype is not link with that date .