2

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?

miken32
  • 39,644
  • 15
  • 91
  • 133

1 Answers1

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