mysql - Adding a value into a field -


inherited 20,000 book database particular field called 'keywords' mess, in 1 huge table called books. trying prepend value each of 'keywords' fields reads words in field , identifies exact category 1 clear phrase.

so, looking word 'ancient' , prepending value 'menu-ancient'.

update books set keywords=concat('menu-ancient, ',keywords)  keywords '%ancient%'; 

that works, following query doesn't want!

it's supposed find ones done , go through them find of them have word 'medieval' in there - give submenu menu-ancient-medieval well.

update books set keywords=concat('menu-ancient-medieval, ',keywords)  keywords = 'menu-ancient' , keywords '%medieval%'; 

one example field this: menu-ancient, war., middle ages, ancient , medieval, ancient 19th century,

i have got menu-ancient prepended getting medieval bit!

you can use find_in_set() function this.

this works in following example :

select * books find_in_set('menu-ancient', keywords) > 0; 

you can apply update query

update books  set keywords=concat('menu-ancient-medieval, ',keywords)   find_in_set('menu-ancient', keywords)   , keywords '%medieval%'; 

note: i'm not quite sure understand second part of question correctly. guess may have alter query use subquery in clause.


Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -