cancel
Showing results for 
Search instead for 
Did you mean: 

Magento sql - Can i join the table totally?

Magento sql - Can i join the table totally?

i want to join a column from customer_entity_varchar to sales_flat_order_grid table.

First of all, i did like this ,

 

  1. ADD NEW COLUMN CALLED AS COMPANY
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?

1 REPLY

Re: Magento sql - Can i join the table totally?

hi @xzxzxzxyy

 

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

 

Reference

Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti