Jump to: navigation, search

Mysql QUOTE

From w3cyberlearnings

Contents

MySQL QUOTE Function

This function returns a proper escaped string for SQL statement.

Syntax QUOTE

  • Str: String to be escaped.
QUOTE(Str);

Note

To properly quote your SQL Statement will prevent some of the SQL injection.

Example 1

mysql> SELECT QUOTE("girl's lovely");
+------------------------+
| QUOTE("girl's lovely") |
+------------------------+
| 'girl\'s lovely'       |
+------------------------+
1 row in set (0.00 sec)

Example 2

mysql> SELECT QUOTE("pasword#'fog'$'");
+--------------------------+
| QUOTE("pasword#'fog'$'") |
+--------------------------+
| 'pasword#\'fog\'$\''     |
+--------------------------+
1 row in set (0.00 sec)

Related Links


Navigation
Web
SQL
MISC
References