Log In · Register

 

Help Topic Rules and Requirements

For a list of all requirements and guidelines pertaining to posting a new Help topic, please click here.

This Month's Contests | Staff Member of the Month | Hosts Looking for Hostees | Hostees looking for Hosts | BigBookofResources

Submission Guidelines

Mysql Syntax
Maccabee
post Feb 27 2011, 10:57 AM
Post #1


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



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.
 
 
Start new topic
Replies
mipadi
post Feb 27 2011, 05:54 PM
Post #2


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



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
post Feb 28 2011, 12:39 AM
Post #3


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



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.
 

Posts in this topic
Maccabee   Mysql Syntax   Feb 27 2011, 10:57 AM
mipadi   Single quotes denote a string. Table and column na...   Feb 27 2011, 05:54 PM
Maccabee   QUOTE(mipadi @ Feb 27 2011, 04:54 PM) Sin...   Feb 28 2011, 12:39 AM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: