'Escaping special characters while inserting in mysql

I am inserting multi-rows in a mysql database by concating values as in the query

INSERT INTO tableName (col1, col2, col3) VALUES('a', 'b', 'c'), ('d', 'b', 'c'), ('e', 'b', 'c');

However, sometimes some of the values of the entire bunch needs to be escaped, like I got s-â€__83164 as one of my values to enter. This causes the entire bunch of request to drop when only one or two of the values are faulty.

Is there any way to escape characters like s-â€__83164 or do I need a modification in the type of field, I am using for it. I am currently using VARCHAR for storing those values.

Please comment if I am unclear in asking my doubt !



Solution 1:[1]

One thing that you can do, is get all characters into variables and then place those variables in your SQL query. While declaring the variable you can use single quotes to include your data.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rahul Kadukar