Skip to main content
1 of 3

Here is the solution. Thanks to In case of multiple deletion, use below 2 query. note that run these SQL in same order as i have written here. First sql query will link orders to customers, and second query will show the orders in the customers account (orders tab)

UPDATE sales_flat_order as SFO  
INNER JOIN customer_entity as C  
ON C.email = SFO.customer_email  
SET SFO.customer_id = C.entity_id  
WHERE SFO.customer_is_guest = 0 
AND FOR sales_flat_order_grid Table

UPDATE sales_flat_order_grid as SFOG  
INNER JOIN sales_flat_order as SFO  
ON SFO.entity_id = SFOG.entity_id  
SET SFOG.customer_id = SFO.customer_id