K
K
knightvoid2014-08-12 12:48:27
MySQL
knightvoid, 2014-08-12 12:48:27

How to correctly change the value of a field from another table (mysql)?

There is a field_data_field_images in which you need to substitute the value for the fields field_images_alt and field_images_title from the title field, but already in the commerce_product table. These tables are connected by a field with id. In field_data_field_images this is the entity_id and in commerce_product this is the product_id.
Something like:
update field_images_alt = title, field_images_title = title
where entity_id = product_id and field_images_alt, field_images_title = empty

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2014-08-12
@knightvoid

You can try like this:

UPDATE field_data_field_images fi SET fi.field_images_alt = (SELECT title FROM commerce_product cp WHERE cp.product_id = fi.entity_id) , fi.field_images_title = (SELECT title FROM commerce_product cp WHERE cp.product_id = fi.entity_id) WHERE fi.field_images_alt = null AND fi.field_images_title = null;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question