Using backquote/backticks for mysql queries

前端 未结 6 513
温柔的废话
温柔的废话 2020-12-09 08:28

I have building MYSQL queries with backticks. For example,

SELECT `title` FROM `table` WHERE (`id` = 3)

as opposed to:

SELE         


        
6条回答
  •  情书的邮戳
    2020-12-09 09:31

    backticks are used to escape reserved keywords in your mysql query, e.g. you want to have a count column—not that uncommon.

    you can use other special characters or spaces in your column/table/db names

    they do not keep you safe from injection attacks (if you allow users to enter column names in some way—bad practice anyway)

    they are not standardized sql and will only work in mysql; other dbms will use " instead

提交回复
热议问题