How to solve this SQL Syntax Error

Discussion in 'MySQL' started by edhan, Jun 1, 2007.

  1. #1
    Hi

    I need help to resolve this SQL Syntax Error. Appreciate anyone can advice as how it can be resolved. Thanks.

    $sq = "select t2.*,t1.* from (select id,name,points from celebrity order by points desc limit 44 ) t1 inner join photos t2 on t1.id = t2.celebid GROUP BY celebid ORDER BY points desc";
    Code (markup):
    I got this error running the above code:

    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 'select id,name,points from celebrity order by points desc limit

    Any advice will be greatly appreciated.
     
    edhan, Jun 1, 2007 IP
  2. zonzon

    zonzon Peon

    Messages:
    100
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hummmmmmm, that seems to be good! wich version of mysql?
     
    zonzon, Jun 1, 2007 IP
  3. ktutorials

    ktutorials Peon

    Messages:
    475
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    nothing looks like error... check version as zonzon said...
     
    ktutorials, Jun 1, 2007 IP
  4. edhan

    edhan Active Member

    Messages:
    364
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Okay. I will check on the version. Thanks!
     
    edhan, Jun 1, 2007 IP
  5. cpucandy

    cpucandy Peon

    Messages:
    489
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I tested your query out on mysql ver 4.1.11 and had no issues.
     
    cpucandy, Jun 1, 2007 IP
  6. edhan

    edhan Active Member

    Messages:
    364
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #6
    My version is 4.0.25. Maybe I should be upgrading to version 4.1.11. Thanks for testing out for me.
     
    edhan, Jun 1, 2007 IP
  7. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #7
    Yes. Subqueries were not supported in MySQL until v4.1
     
    krt, Jun 2, 2007 IP