7

I am new to SQL and still learning but one thing I am confused about is where we use ` and ' operators in MySQL/MariaDB. Can anyone explain this?

miken32
  • 42,008
  • 16
  • 111
  • 154
  • 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
  • 1
    Possible 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

1 Answers1

13

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, rather than the string value "bob":

SELECT * FROM mydb.users WHERE username = bob;
miken32
  • 42,008
  • 16
  • 111
  • 154