sql - Make Update with select statement in Mysql -


i trying update products category in database. error , and dont understand statement wrong. please help. find products have in name specific word , after update category products.

i want select ids sho_posts sho_posts.post_title contain part of word '%audio cd%' , after update sho_term_relationships.term_taxonomy_id value 2 sho_term_relationships.object_id=sho_posts.id

update sho_term_relationships     set term_taxonomy_id = 2  object_id = (select `id` `1876522_shoping`.`sho_posts` convert(`post_title` using utf8) '%audio cd%')  

in clause, find ids update based on subquery results, use in instead of =

update sho_term_relationships     set term_taxonomy_id = 2    object_id in (       select `id` `1876522_shoping`.`sho_posts`        convert(`post_title` using utf8) '%audio cd%')  

you use = if subquery return single row, won't work if subquery returns multiple rows. using in tests whether object id included in subquery results.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -