Google Answers Logo
View Question
 
Q: SQL syntax question (mySQL) ( No Answer,   1 Comment )
Question  
Subject: SQL syntax question (mySQL)
Category: Computers > Programming
Asked by: davidsch-ga
List Price: $7.00
Posted: 18 Feb 2005 16:38 PST
Expires: 18 Feb 2005 21:38 PST
Question ID: 476871
SQL syntax: I am working with mySQL. How do I write a SQL statement
which updates a table as follows:

- In table "Table_X",
- For field "Field_Y", which is of type char(64),
- For each record that contains one or more instances of the string
"ab" in "Field_Y",
- Replace "ab" with "cde" for all instances of "ab".
Answer  
There is no answer at this time.

Comments  
Subject: Re: SQL syntax question (mySQL)
From: goodfoo-ga on 18 Feb 2005 20:12 PST
 
MySQL 4.1 has nice function called REPLACE - most engines do not have such a thing.

http://dev.mysql.com/doc/mysql/en/string-functions.html

For your example:

update Table_X set Field_Y = replace(Field_Y, 'ab', 'cde' );

The double reference to Field_Y is allowed.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy