web_master Posted June 21, 2007 Share Posted June 21, 2007 hi, can somebodz tell me what is the difference between quoted and not quoted sql column names? $query = mysql_query("SELECT * FROM table WHERE row = '$row'"); OR $query = mysql_query("SELECT * FROM `table` WHERE `row` = '$row'"); thankx Link to comment https://forums.phpfreaks.com/topic/56531-solved-difference-between-quoted-and-not-quoted-sql-column-names/ Share on other sites More sharing options...
trq Posted June 21, 2007 Share Posted June 21, 2007 They are not quotes, but backticks. Quotes will cause a syntax error. Backticks are used to escape reserved words. For instance, DESC is a reserved word in sql. If you wanted to have a filed name called DESC, you'd need to surround it with backticks. IMO, reserved words should be avoided (they are after, reserved for a reason). They do nothing but cause confusion. If you never use reserved words, you have no need at all for backticks. Link to comment https://forums.phpfreaks.com/topic/56531-solved-difference-between-quoted-and-not-quoted-sql-column-names/#findComment-279200 Share on other sites More sharing options...
web_master Posted June 21, 2007 Author Share Posted June 21, 2007 They are not quotes, but backticks. Quotes will cause a syntax error. Backticks are used to escape reserved words. For instance, DESC is a reserved word in sql. If you wanted to have a filed name called DESC, you'd need to surround it with backticks. IMO, reserved words should be avoided (they are after, reserved for a reason). They do nothing but cause confusion. If you never use reserved words, you have no need at all for backticks. I see, thnax for answer! Link to comment https://forums.phpfreaks.com/topic/56531-solved-difference-between-quoted-and-not-quoted-sql-column-names/#findComment-279203 Share on other sites More sharing options...
ToonMariner Posted June 21, 2007 Share Posted June 21, 2007 I use backticks all teh time in my code just to differentiate between fields and values... I fin it helps but as thorpey says - it's not neccessary. Link to comment https://forums.phpfreaks.com/topic/56531-solved-difference-between-quoted-and-not-quoted-sql-column-names/#findComment-279228 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.