i want to join a column from customer_entity_varchar to sales_flat_order_grid table.
First of all, i did like this ,
ALTER TABLE sales_flat_order_grid ADD company varchar;
2. UPDATE COMPANY BY GETTING THE DATA FROM customer_entity_varchar
UPDATE sales_flat_order_grid SET company = (SELECT value from customer_entity_varchar where sales_flat_order_grid.customer_id = customer_entity_varchar.entity_id AND customer_entity_varchar.attribute_id = 1053)
Btw, it THIS CODE IS JUST INSERTING PRESENT DATA! I MEAN I WANT TO JOIN TABLE AND UPDATE IT TOTALLY! WHAT SHOULD I DO?
Here is query not tested but hope it will work.
UPDATE sales_flat_order_grid a JOIN customer_entity_varchar b ON a.customer_id= b.entity_id AND b.attribute_id= 1053 SET a.company= b.value