Inserting backslash in mysql

Consider the below table for your clear understanding of backslash insertion in mysql,

create the myday table with two attributes (say a and b),

I am inserting the example below data’s,

Insert into myday (a,b) values ("naveen","javadomain\java");

If you see the table data’s will be look likes below one,

naveen javadomainjava. (no backslash)

In order to solve this problem we can consider anyone of the below solutions,

1. Use the preparedstatements to insert the data’s.

2. use two backslashes(one for insertion, another for escaping the insertion backslash),

insert into myday (a,b) values ("naveen","javadomain\\java");

Now you can see the data’s like this in the table,

naveen javadomain\java.

 

Thank you for reading this post…………….!!!

Leave a Reply