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
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.

Link to comment
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.

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.