String delimiters (MySQL): verschil tussen versies
Naar navigatie springen
Naar zoeken springen
(Nieuwe pagina aangemaakt met 'I use to use " as string delimiters. However (2022.08): That's not how MySQL wants me to do it → Use ' to avoid complications like with escaping. == Sources ==...') |
|||
Regel 1: | Regel 1: | ||
I use to use " as string delimiters. However (2022.08): That's not how MySQL wants me to do it → Use ' to avoid complications like with escaping. | I use to use " as string delimiters. However (2022.08): That's not how MySQL wants me to do it → Use ' to avoid complications like with escaping. | ||
+ | |||
+ | [https://stackoverflow.com/questions/881194/how-to-escape-special-character-in-mysql/881252#881252]: | ||
+ | |||
+ | <pre> | ||
+ | You should use single-quotes for string delimiters. The single-quote is the standard | ||
+ | SQL string delimiter, and double-quotes are identifier delimiters (so you can use | ||
+ | special words or characters in the names of tables or columns). | ||
+ | |||
+ | In MySQL, double-quotes work (nonstandardly) as a string delimiter by default (unless | ||
+ | you set ANSI SQL mode). If you ever use another brand of SQL database, you'll benefit | ||
+ | from getting into the habit of using quotes standardly. | ||
+ | </pre> | ||
== Sources == | == Sources == | ||
* https://stackoverflow.com/questions/881194/how-to-escape-special-character-in-mysql/881252#881252 | * https://stackoverflow.com/questions/881194/how-to-escape-special-character-in-mysql/881252#881252 |
Huidige versie van 27 aug 2022 om 11:48
I use to use " as string delimiters. However (2022.08): That's not how MySQL wants me to do it → Use ' to avoid complications like with escaping.
[1]:
You should use single-quotes for string delimiters. The single-quote is the standard SQL string delimiter, and double-quotes are identifier delimiters (so you can use special words or characters in the names of tables or columns). In MySQL, double-quotes work (nonstandardly) as a string delimiter by default (unless you set ANSI SQL mode). If you ever use another brand of SQL database, you'll benefit from getting into the habit of using quotes standardly.