TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   MySQL & Databases (http://www.talkphp.com/mysql-databases/)
-   -   Why use `? (http://www.talkphp.com/mysql-databases/2306-why-use.html)

Aaron 02-21-2008 12:29 PM

Why use `?
 
I see people putting "`" around input for the SQL, why?

Wildhoney 02-21-2008 02:03 PM

Oh I get you now. Blond moment!

Basically the back-ticks should only be around the table names for the very reason that it distinguishes between a user string and a reserved word in MySQL:

sql Code:
SELECT count FROM DESC

Whereas the back-ticks tell MySQL that count and desc are user entities, and not MySQL commands:

sql Code:
SELECT `count` FROM `desc`

Village Idiot 02-21-2008 03:11 PM

-It defines commands from user entities as wild pointed out
-It looks cleaner in my opinion

I personally find it good coding to use the brackets so that if you accidentally name a table or field a command name, you wont have to worry about an error.

wGEric 02-21-2008 06:21 PM

No one said this directly but hinted at it ... I believe the back ticks are MySQL specific.


All times are GMT. The time now is 06:17 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0