1
votes

I have two tables: ps_product_shop and ps_product.

I want update a column in ps_product_shop with this command:

UPDATE `ps_product_shop` 
SET dm_heureka_product_sk = 'Text' 
AND (SELECT reference from ps_product where id_product = 508) where id_product = 508

I get this error:

#1292 - Truncated incorrect DOUBLE value: 'Text'

How can I insert text + (SELECT reference from ps_product where id_product = 508) ?

Command "Select" take value from ps_product table and from column "reference"

Server mysql: Server version: 5.7.24

Thanks for help.

2

2 Answers

1
votes

If reference is unique for id_product you can use CONCAT() as such

UPDATE ps_product_shop SET dm_heureka_product_sk = CONCAT('Text', (SELECT reference from ps_product where id_product = 508) where id_product = 508
0
votes

This can be achieved with a mysql UPDATE JOIN :

UPDATE ps_product_shop pps
INNER JOIN ps_product pp ON pp.id_product = pps.id_product
SET pps.dm_heureka_product_sk = CONCAT('Text', pps.reference)
WHERE pps.id_product = 508