What the !%$&. Weird MySQL issue.

Discussion in 'MySQL' started by AYCOM, Jan 25, 2008.

  1. #1
    Ok, so why would this work:
    "SELECT * FROM conference WHERE ConferenceID = 70"

    but not this:
    "SELECT * FROM group WHERE ContextID = 18"

    Mind you that conference and group are both tables in the same database. The second spits back a MySQL query error:
    "Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group WHERE ContextID =18' at line 1"

    HOWEVER! After playing around for 4 hours I found that this works:
    "SELECT * FROM `group` WHERE `ContextID` =18"

    Why? I have never had to use retarded syntax like that. I don't even know how to make that dumb apostrophe thing without copy/pasting it out of phpMyAdmin. lol =)

    I really appreciate any ideas you guys have!
     
    AYCOM, Jan 25, 2008 IP
  2. sharqi

    sharqi Guest

    Messages:
    105
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    'try' 'encapsulating' 'your' 'values' 'and' 'see' 'if' 'it' helps'
     
    sharqi, Jan 25, 2008 IP
  3. atomsplash

    atomsplash Peon

    Messages:
    167
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes, do that. GROUP BY is a MySQL function, so the unencapsulated group may be throwing that error. It sees group and is associating GROUP BY. Encapsulating is just good practice as well.
     
    atomsplash, Jan 25, 2008 IP
  4. AYCOM

    AYCOM Peon

    Messages:
    33
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Man I was totally looking at this issue from the wrong direction! Thanks!
     
    AYCOM, Jan 25, 2008 IP