Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Query update per modificare stringa nel record

    Ciao,
    avrei necessità di aggiornare i record di un database: vorrei fare una query che ogni volta che trova una determinata stringa all'interno di un record, la sostituisca con una stringa diversa.

    Come posso costruire una query di Update adatta al mio scopo?

    Grazie

  2. #2
    Uh, ho trovato
    You sometimes run into the problem that you want to replace a substring occuring in a column with a different string, without touching the rest of the string. The solution is surprisingly simple, thanks to MySQL:

    UPDATE xoops_bb_posts_text
    SET post_text=(
    REPLACE (post_text,
    'morphix.sourceforge.net',
    'www.morphix.org'));

    using the string function REPLACE, all items in the post_text column with 'morphix.sourceforge.net' get this substring replaced by 'www.morphix.org'. Ideal when writing a script is just too much effort.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.