October 19th, 2012, 09:34 AM
What symbol to use instead?
I hope I can make sense and get an answer..
I'm trying to update a field on a table..
This field contains different forwarding methods for a message.
For Example: EIioT which stands for Email Immediately incoming outgoing T (not sure)
If I want to change for only incoming I can change it to: EIiT but this way, if the first letter was S (for SMS) will default all to E (email).
How can I just modify/add/remove a letter in the middle without effecting others?
I tried * and ?..
Hope yopu can help..
Regards to all
October 19th, 2012, 11:42 AM
The WHERE LIKE is to explicitly choose the rows that need to be updated.
yourColumn = REPLACE(yourColumn, 'x', 'y')
yourColumn LIKE '%x%'
October 22nd, 2012, 06:09 AM
Thank you Stephan..
can't get it though..
Set FORWARD_DETAILS = '%IioT'
out of all the above letters I want only the first not to be touched...
do I need the % sign at the end too?
October 22nd, 2012, 06:18 AM
This is what I wrote:
FORWARD_DETAILS = REPLACE ( FORWARD_DETAILS ' i ' , ' io ' )
FORWARD_DETAILS LIKE ' %i% '
October 22nd, 2012, 08:25 AM
And what is the error message that you get?
Could it be:
And by looking and stepping through this code I can see that:
mysql> update MESSAGE_ACTIONS
-> FORWARD_DETAILS = REPLACE ( FORWARD_DETAILS ' i ' , ' io ' )
-> FORWARD_DETAILS LIKE ' %i% ';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL serv
er version for the right syntax to use near '' i ' , ' io ' )
FORWARD_DETAILS LIKE ' %i% '' at line 3
1. You don't have a comma between the column name FORWARD_DETAILS and the 'i'.
2. You have spaces between the ' sign and the letter i and the letters io, which means that mysql is right now trying to replace the string '(space)i(space)' with the string '(space)io(space).
3. You have spaces inside the string in LIKE also.
So try this instead:
FORWARD_DETAILS = REPLACE ( FORWARD_DETAILS, 'i' , 'io' )
FORWARD_DETAILS LIKE '%i%'