Help - Search - Members - Calendar
Full Version: Mysql Syntax
Forums > Resource Center > Webmasters' Corner
Maccabee
This code doesn't work.
CODE
SELECT * FROM 'bookmarks' WHERE 'group' = 'Social'

This code does.
CODE
SELECT * FROM `bookmarks` WHERE `group` = 'Social'

The working code was generated by phpmyadmin. I've seen those diagonal single quote marks, nor have I read anything about them in php books/tutorials/etc. What are they, and how do I even make them? I feel stupid asking this but I just spent an hour trying to figure out why my sql query wasn't working and that appears to be the only difference.
mipadi
Single quotes denote a string. Table and column names are not strings, thus you can't use single quotes. However, some databases allow you to use backticks (`) around table and column names. Personally, I never use backticks around table/column names.
Maccabee
QUOTE(mipadi @ Feb 27 2011, 04:54 PM) *
Single quotes denote a string. Table and column names are not strings, thus you can't use single quotes. However, some databases allow you to use backticks (`) around table and column names. Personally, I never use backticks around table/column names.

Oh, so I could have just been using:
CODE
SELECT * FROM bookmarks WHERE group = 'Social'

That makes sense, thanks Michael.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.