Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to change every apostrophe( ' )with a space in MySQL table Column .

Error message is about syntaxe echec !

What I have tried:

string query = "update database.table set column = column.Replace('"+"'"+"','"+" "+"');" ;
Posted
Updated 27-Oct-17 1:15am
v2

Use ALTER TABLE[^]
 
Share this answer
 
Comments
phil.o 27-Oct-17 8:26am    
ALTER statement is for modifying a table's schema, not the values which are stored in its columns.
A_Griffin 27-Oct-17 8:31am    
Yes, sorry - I misread the question
If you want to escape a single quote in a MySQL string, you have two ways of doing it:
1. make it two single quotes:
C#
string query = "update database.table set column = column.Replace('''',' ');" ;

2. use the escape character (\):
C#
string query = @"update database.table set column = column.Replace('\'',' ');" ;

In the second solution you have to prefix your c# string with the @ character, so that the compiler does not interpret the escape character in sthe string as a C# escape character (and thus leaves this as it is).
Kindly.
 
Share this answer
 
Comments
EM_Y 27-Oct-17 7:06am    
thank you it works ^^
phil.o 27-Oct-17 7:21am    
You're welcome :)
Try :
SQL
update database.table set column = REPLACE(column, '\'', ' ')
 
Share this answer
 
Comments
EM_Y 27-Oct-17 6:57am    
Thank you but it doesn't work .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900