i been reading and trying alot of the answers to similiar problem. i need to update table test field brand with the content of field name from table brands. i do this select to check fields that need to be update:
SELECT brand.name,test.`1_name`
FROM test INNER JOIN brand
ON test.`1_name` LIKE CONCAT('%',brand.name,'%')
the above give me a result of 32000 records. i try to use that select inside an update with
UPDATE `test` SET brand=(....)
but couldnt get it to work.
Try this :
UPDATE `test` SET brand=(SELECT brand.name FROM test INNER JOIN brand ON test.`1_name` LIKE CONCAT('%',brand.name,'%'))
The query you posted returns a collections of data ( SELECT brand.name,test.1_name
... ),
SET brand = ` needs a scalar value.
In other words, ensure that your query returns only one result.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.