Home  >  Article  >  Database  >  What are mysql escape characters?

What are mysql escape characters?

coldplay.xixi
coldplay.xixiOriginal
2020-11-17 09:30:078882browse

The mysql escape character is [`], which is used to avoid keyword conflicts between column names or table names and mysql itself. It is usually used to indicate that the contents are database names, table names, and field names, not keywords. .

What are mysql escape characters?

` is the MySQL escape character, used to avoid keyword conflicts between column names or table names and mysql itself.

All databases have similar settings, but mysql uses `. It is usually used to indicate that the contents are database names, table names, and field names, not keywords. For example:

select * from table_name where `key` = 'key_name';

Among them, key is the keyword of mysql. If the column name is key, it needs to be escaped with ``.

Extension: \ needs to be used in the string to escape `, otherwise an error will be reported with a syntax error.

mysql -uUser -pPasswd -e "select * from table_name where \`key\` = 'name';"

More related free learning recommendations: mysql tutorial(video)

The above is the detailed content of What are mysql escape characters?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn