After reading a couple of answers and comments on some SQL questions here, and also hearing that a friend of mine works at a place which has a policy which bans them, I'm wondering if there's anything wrong with using backticks around field names in MySQL.
That is:
SELECT `id`, `name`, `anotherfield` ...
-- vs --
SELECT id, name, anotherfield ...
If you ask to me, backticks should always be used. But there are some reasons why a team may prefer not to use them.
Advantages:
Disadvantages:
if you are using some field names as default mysql or mssql values for example "status", you have to use backticks ( "select
status
from table_name" or "select id from table_name wherestatus
=1" ). because mysql returns errors or doesnt work the query.Well, as far as I know, the whole purpose of using backticks is so you can use names that coincide with reserved keywords. So, if the name isn't colliding with a reserved keyword, I don't see any reason to use backticks. But, that's no reason to ban them, either.
It's a lot easier to search your code-base for something in backticks. Say you have a table named
event
.grep -r "event" *
might return hundreds of results.grep -r "\`event\`" *
will return anything probably referencing your database.