What's the symbol of escape-sequence in SQL?
INSERT INTO table (id,sentence) VALUES(NULL, concat('The \'id is ',id))
is it correct to use the symbol '\' ?
or is it better to use '' (2 single quotes) to express the character ' ?
Is there a standard definition about that?
Thanx
--
Don HO
http://notepad-plus.sourceforge.net/
a powerful free (and open source) multi-function editor
At least in MySQL (could be different in mssql) you use the '\' infront of the
character.
//Aho
>What's the symbol of escape-sequence in SQL?
>
>INSERT INTO table (id,sentence) VALUES(NULL, concat('The \'id is ',id))
>
>is it correct to use the symbol '\' ?
>or is it better to use '' (2 single quotes) to express the character ' ?
It Depends. Different databases use different rules.
For MySQL, slash. For Oracle, two single quotes.
>Is there a standard definition about that?
The draft of ANSI SQL-99 I've got has the following production for string
literals:
<general literal> ::=
<character string literal>
| <national character string literal>
| <bit string literal>
| <hex string literal>
| <datetime literal>
| <interval literal>
<character string literal> ::=
[ <introducer><character set specification> ]
<quote> [ <character representation>... ] <quote>
[ { <separator>... <quote> [ <character representation>... ]
<quote> }... ]
<introducer> ::= <underscore>
<character representation> ::=
<nonquote character>
| <quote symbol>
<nonquote character> ::= !! See the Syntax Rules.
<quote symbol> ::= <quote><quote>
Therefore the standard says two single quotes.
--
Andy Hassall <an...@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
> The draft of ANSI SQL-99
SQL-92, even.
--
Don HO
http://notepad-plus.sourceforge.net/
a powerful free (and open source) multi-function editor
"Andy Hassall" <an...@andyh.co.uk> a écrit dans le message de news:
e86s909tnp8srq52b...@4ax.com...