V
V
vladkuzmenko952016-10-31 18:56:37
SQL
vladkuzmenko95, 2016-10-31 18:56:37

Why write backticks in sql queries?

Hello!
I meet 2 types of sql queries:
1) SELECT `id` FROM `table` WHERE `column` = 'value'
2) SELECT id FROM table WHERE column = 'value'
From here I have a question, why do I need to write apostrophes in a sql query and which option 1 or 2 is more correct and why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2016-10-31
@vladkuzmenko95

why do you need to write apostrophes in sql query
This is escaping in case of using reserved words in table and column names.
which option 1 or 2 is more correct and why
It is correct to write with escaping, because the names can come from anywhere and anything can be there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question