MySQL Forums
Forum List  »  Newbie

Re: Deleting a substring with a wildcard?
Posted by: Jay Pipes
Date: June 30, 2005 10:34AM

Wildcards don't work in the replace function like that, unfortunately. What you can do is use the CONCAT(), LEFT(), RIGHT(), and INSTR() functions to get to the left and right parentheses:

mysql> SET @string = 'I am (not) confused';
Query OK, 0 rows affected (0.20 sec)

mysql> SELECT CONCAT(LEFT(@string, INSTR(@string, '(') -1), RIGHT(@string, LENGTH(@string) - INSTR(@string, ')')-1));
+--------------------------------------------------------------------------------------------------------+
| CONCAT(LEFT(@string, INSTR(@string, '(') -1), RIGHT(@string, LENGTH(@string) - INSTR(@string, ')')-1)) |
+--------------------------------------------------------------------------------------------------------+
| I am confused |
+--------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Written By
Posted
Re: Deleting a substring with a wildcard?
June 30, 2005 10:34AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.