Jump to content

Query `syntax` or just syntax ?


flyhoney

Recommended Posts

It appears that mysql queries work without the `` most of the time, but sometimes it complains, why?

 

works most of the time:

$query = "SELECT * FROM table WHERE this='$that'";

but sometimes complains and needs:

$query = "SELECT * FROM `table` WHERE this='$that'";

 

why?

Link to comment
https://forums.phpfreaks.com/topic/46814-query-syntax-or-just-syntax/
Share on other sites

So maybe my table name is a reserved word?  That makes sense.  Sorry, I took the time and did a little more googling and it seems there are several reasons backticks are necessary, I guess I'll just get in the habit of using them.  Never seemed to be a problem on DB2 or Oracle.  Thanks.

So maybe my table name is a reserved word?  That makes sense.  Sorry, I took the time and did a little more googling and it seems there are several reasons backticks are necessary, I guess I'll just get in the habit of using them.  Never seemed to be a problem on DB2 or Oracle.  Thanks.

I have never found quoting necessary but there usage is probably good coding practice.

 

I disagree -- if you get into the habit of NOT using them, you'll learn the reserved keywords and never have a problem.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.