Skip to content

I can select specific columns to update using the `updateFromSelect` function for mass updates?

I try to massivle update a specific column from 1 table to another using the updateFromSelect function:

   $table = 'mytable';
   /**
    * @var $resource MagentoFrameworkDBAdapterPdoMysqlInterceptor
    */
   $select = $resource->select()
            ->join($table,$table.'.email=customer_entity.email')
            ->where($table.".valid",true)
            ->where($table.".customer_group_id<>customer_entity.group_id")
            ->columns([$table.'.customer_group_id as group_id']);

   $sql=$resource->updateFromSelect($select,'customer_entity');

But the $sql value is:

UPDATE `customer_entity`
 INNER JOIN `mytable` ON mytable.email=customer_entity.email
SET `customer_entity`.`*` = `mytable`.`*`, `customer_entity`.`group_id` = `mytable`.`customer_group_id`
WHERE (mytable.valid) AND (mytable.customer_group_id<>customer_entity.group_id)

As you can see the generated SQL query contains this part:

`customer_entity`.`*` = `mytable`.`*`,

Is there a way to remove it whitout resolving into str_replace or preg_replace?

str_replace("`customer_entity`.`*` = `mytable`.`*`,","",$sql);