0

I'm trying to insert a multiple line string into my MySQL db.

Example:

INSERT INTO `dressuurpaardje`.`Marks` (`markID`, `testID`, `markPosition`, `techinicalMark`, `directiveIdeas`, `maxMark`, `coefficient`, `overflow`) 
VALUES (NULL, 1, 'M', 'Proceed in passage ' + CHAR(10) + CHAR(13) + ' Transition collected walk - passage', NULL, 10, NULL, NULL);

I use ' + CHAR(10) + CHAR(13) + ' with the intention to get a newline in the string. But this puts the string "0" in my db

Any suggestions?

4

1 回答 1

1
  1. Use '\n' in your query, and let the text interpreter add the line (depends what you use, but that's what I would recommend)
  2. Use CONCAT(string1, CHAR(10), CHAR(13), string2), as mentionned also by Mazatwork.

Be aware that CHAR10 + CHAR13 is wrong. A line feed / carriage return is either:

  • chr10 or \n (unix)
  • chr13 + chr10 or \r\n (windows)
于 2013-04-20T20:47:39.270 回答