如何在同一个字段上运行两次替换的选择?
SELECT `id`, `name`, `address`, REPLACE( `info`, '|', '-' ) AS `info`
INTO OUTFILE '/tmp/" . $SESSION . "NET_SCAN.csv'
FIELDS TERMINATED BY '|'
ENCLOSED BY ''
LINES TERMINATED BY '\n'
FROM `net_scan`;
我想在同一个字段上运行辅助REPLACE。
答案 0 :(得分:4)
只需在其中使用REPLACE
。
REPLACE(REPLACE(field, 'bad', 'good'), 'better', 'worse')
答案 1 :(得分:2)
replace(REPLACE( `info`, '|', '-' ), 'x', 'y'))