Char(13) + char(10 in mysql)
Answers
I assume you want to remove both chr(13) and chr(10) from a varchar column.
the result is
for both values it would be
EDIT The sign for a line break in PHP and several other languages is \n, the sign for a carriage return is \r. Depending on the system thus \r\n or just \n is a newline, while sometimes also the \n implicitly stands for \r\n. But what about MySQL? How can we explicitly look for line breaks, for example, to replace a line break with another string. To specify a line break in MySQL, we need the function CHAR(). CHAR() takes an ASCII code and returns the corresponding character. The code for a line break is 10, for a carriage return it is 13. So we can express the following MySQL query for example: UPDATE tab SET col = REPLACE(col, CHAR(13, 10), ''); With this, we replace all line breaks of the type \r\n with nothing - that is, we delete the line breaks. Other types of line breaks can of course be replaced in the same way by using the corresponding character codes. Instead of writing CHAR(13,10) we can also write CHAR(13) + CHAR(10), which means the same. Using the plus we create a string consisting of the character with code 13 and the character with code 10. Because CHAR() can take multiple parameters, with CHAR(13,10) we get the same result. For functions that operate on string positions, the first position is numbered 1. For functions that take length arguments, noninteger arguments are rounded to the nearest integer.
How do I use CHAR 13 in SQL?Use CHAR to insert control characters into character strings. This table shows some frequently used control characters.
...
Remarks.. What is a CHAR 13?The ASCII character code 13 is called a Carriage Return or CR . On windows based computers files are typically delimited with a Carriage Return Line Feed or CRLF .
What is a CHAR 10?CHAR(10) is the character represented by ASCII code 10, which is a Line Feed (\n) so its a new line. (Although its not the windows standard new line which is Carriage Return + Line Feed CHAR(13)+CHAR(10) ) In your example its probably just used to make the string more readable when its printed out.
What does CHAR () mean in SQL?The CHAR() function returns the character based on the ASCII code.
|