Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL: Difference between ', `, ´ and "

Tags:

string

mysql

When seeing SQL code on the internet and in manuals there seems to vary a lot what is used to signify strings (or at least that's what I think they do?).

Are there any difference between using `, ´, ' or "? Are they all the same? Or do some of them have special meanings? Should some be used in certain cases and others in other cases? What is the deal here?

like image 991
Svish Avatar asked Apr 20 '10 06:04

Svish


People also ask

What is the difference between AND and/or in MySQL?

The difference between AND, OR is that AND evaluates both conditions must be true for the overall condition to be true. The OR evaluates one condition must be true for the overall condition to be true. In the OR result, if name is John then condition will be true. If any row has the age 22, then it will be true.

What is difference between AND and/or in SQL?

The SQL AND, OR and NOT Operators The AND and OR operators are used to filter records based on more than one condition: The AND operator displays a record if all the conditions separated by AND are TRUE. The OR operator displays a record if any of the conditions separated by OR is TRUE.

What is the difference between & AND && in SQL?

NOTE: There is only one difference between AND and && is that AND is a standard while && is ownership syntax.

What does && mean in MySQL?

MySQL logical AND operator compares two expressions and returns true if both of the expressions are true. Syntax: AND, && This operator returns 1 if all operands are nonzero and not NULL, 0 if one or more operands are 0, otherwise, NULL is returned.


2 Answers

Backticks (`) are required when identifiers, such as column names, are using names which also happen to be reserved words. For example, since from is a reserved word, you would have to wrap a from column name in backticks, as follows:

SELECT `from`, to FROM messages WHERE to = 'Joe';

Also note how the string in the WHERE clause had to be wrapped in quotes. This is also required.

Further reading:

  • Reserved Words in MySQL 5.1
like image 151
Daniel Vassallo Avatar answered Sep 30 '22 06:09

Daniel Vassallo


`` delimits identifiers and ' and " delimits strings. there are no difference between last two

´ has no meaning in mysql

like image 39
Your Common Sense Avatar answered Sep 30 '22 05:09

Your Common Sense