SQL query to prepend prefix to existing value in a field

后端 未结 4 732
夕颜
夕颜 2021-01-31 04:12

I have searched and searched for an answer to this, and I think this must be child\'s play for anyone who KNOWS SQL (which is not me).

I want to insert a prefix to the v

4条回答
  •  醉梦人生
    2021-01-31 04:38

    You have no other conditions like update this in all rows then you can try

    UPDATE jos_content SET title = CONCAT('Mr. ', title) 
    

    if you want to update conditionally that means particular row needs to update the you can use

     UPDATE jos_content SET title = CONCAT('Mr. ', title)  where fiedl_name ='condition'
    
    eg: UPDATE jos_content SET title = CONCAT('Mr. ', title)  where id = '1'
    

    this will update only one row which contain id=1.

    any way before doing this should keep a backup

提交回复
热议问题