I am new to SQL and still learning but one thing I am confused about is where we use ` and ' operators in SQL. Can anyone explain this?
Asked
Active
Viewed 3,215 times
2
miken32
- 39,644
- 15
- 91
- 133
-
http://stackoverflow.com/questions/10573922/what-does-the-sql-standard-say-about-usage-of-backtick – Kamil Gosciminski Feb 18 '17 at 18:33
-
update you question and add a proper sample realted to your question – ScaisEdge Feb 18 '17 at 18:43
-
1Possible duplicate of [When to use single quotes, double quotes, and backticks in MySQL](http://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql) – chris85 Feb 18 '17 at 18:46
-
@miken-Happy Now? – Sep 13 '17 at 19:11
1 Answers
8
Backticks (`) are used to indicate database, table, and column names. Unless you're using reserved or conflicting words for table and database names, you'll not need to use them.
Quotes (' or ") are used to delimit strings, and differentiate them from column names.
For example:
SELECT * FROM `database`.`table` WHERE `column` = "value";
As I mentioned, backticks aren't needed, if you use reasonable table and column names:
SELECT * FROM mydb.users WHERE username = "jim";
But strings will always need quotes. This query is comparing the value in the column username against a value in the column bob:
SELECT * FROM mydb.users WHERE username = bob;
miken32
- 39,644
- 15
- 91
- 133