Навигация по разделуВсе категорииБолталкаЗаметкиPHP
Свернуть категорию PHPДобавить в категорию
Mysql поиск и замена текста
Add to favorites 
Добавлено : 2008-01-23 06:55:53 . Пользователем : BOSS . Все предложения : BOSS . Просмотров - 3311
The syntax of REPLACE is REPLACE(text_string, from_string, to_string)


MySQL reference describes REPLACE as function that returns the string text_string with all occurrences of the string from_string replaced by the string to_string, where matching is case-sensitive when searching for from_string. text_string can be retrieved from the a field in the database table too. Most SQL command can be REPLACE() function, especially SELECT and UPDATE manipulation statement.

For example:

update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);

update client_table set company_name = replace(company_name, ‘Old Company’, ‘New Company’)

The above statement will replace all instances of ‘Old Company’ to ‘New Company’ in the field of company_name of client_table table.

Another example:

SELECT REPLACE(’www.mysql.com’, ‘w’, ‘Ww’);

Above statement will return ‘WwWwWw.mysql.com’ as result.

Ключевые слова :

Для добавления вашего коментария вы должны авторизоваться , если вы не зарегистрированы то зарегистрируйтесь .


Shop4guru © v.3.1.1, Copyright © 2005-2008, 4gu.ru Ltd. Русская версия: Shop4guru ™