1

I have some text and I want to add it to a mysql table. The problem is that the text includes commas, and when I try to do an INSERT, it detects more arguments.

Let's see an example.

INSERT INTO 'video' (tittle_id, text, level) VALUES (20140531190530, Hi, this is the video text, I hope you like it, 90)

As you can see, it detects Hi, this is the video text, and I hope you like it as three different arguments.

Is there a way to solve it?

Thanks in advance :)

Neoares
  • 439
  • 11
  • 24
  • 1
    its not about escaping comma you need to use single quote for the string values and if possible PDO – Abhik Chakraborty Jun 04 '14 at 11:34
  • possible duplicate of [When to use single quotes, double quotes, and backticks?](http://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks) – fancyPants Jun 04 '14 at 11:34
  • 1
    I gave a plus point for the question, after someone downvoted, as when eg doing group_concat of distinct values, and data wrangling result in another query, I personally find it easy to forget, even momentarily, this is what is going on - I searched for escape commas in mysql, as others may do, and am reminded neatly here, that I need to remember some of the group_concat results have comma in the string, so need put quotes in right place when constructing new query! I think this is good question title and question, so people can quickly correct a common misunderstanding I suspect... – Will Croxford Sep 01 '21 at 17:39

2 Answers2

1

Try using single quotes:

INSERT INTO 'video' (tittle_id, text, level) 
VALUES (20140531190530, 'Hi, this is the video text, I hope you like it', 90)
Raging Bull
  • 18,593
  • 13
  • 50
  • 55
1

Put Hi, this is the video text, I hope you like it inside single quotes, like this:

INSERT INTO 'video' (tittle_id, text, level) 
VALUES (20140531190530, 'Hi, this is the video text, I hope you like it', 90)
Thanos Markou
  • 2,587
  • 3
  • 25
  • 32