info:mysql:replace

Ceci est une ancienne révision du document !


Pour remplacer des chaînes de caractères dans des bases de données MySQL

http://sql.sh/fonctions/replace

  REPLACE(str,from_str,to_str)

Returns the string str with all occurrences of the string from_str replaced by the string to_str. REPLACE() performs a case-sensitive match when searching for from_str.

mysql> SELECT REPLACE('www.mysql.com', 'w', 'Ww');
        -> 'WwWwWw.mysql.com'

UPDATE table
SET nom_colonne = REPLACE(nom_colonne, 'ancien texte', 'texte de remplacement')

ex:
UPDATE dc_post 
SET post_excerpt = replace(post_excerpt,"cms/dotclear","blog");

ex. avec php

$replace = mysql_query("
replace into 
recet (id, prov, titre, temps, ingr, pers, typ, prep, date) 
VALUES 
('$id', '$prov', '$titre', '$temps', '$ingr', '$pers', '$typ', '$prep', '$date')");

UPDATE

update sr_data set email='@bcu.unil.ch' where email='FR'
# update signets 
set category='Geneve_et le_monde' 
where category='Genève_et le_monde' 
  • info/mysql/replace.1679319226.txt.gz
  • Dernière modification : 2023/03/20 14:33
  • de radeff