Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Parsing error in mysql query with case

Options
  • 09-01-2010 3:42pm
    #1
    Closed Accounts Posts: 38


    I'm getting a 1064 parse error in phpMyAdmin when trying to debug the following query (minus the php code of course). The server is using MySQL 3.23.29. I've checked and rechecked the syntax, but can't see where the error is.
    [PHP]
    $query = "SELECT rollno
    CASE
    WHEN (@modules := COUNT(code)) <= 5 THEN '1-5 modules'
    WHEN @modules >= 6 THEN '6-10 modules'
    WHEN @modules >= 11 THEN '11-15 modules'
    WHEN @modules >= 16 THEN '16-20 modules'
    WHEN @modules >= 21 THEN '21-30 modules'
    ELSE 'Over 30 modules'
    END AS modules_provided
    FROM centres
    WHERE year = '2006'";
    [/PHP]
    Would be obliged if you would have a quick look. Thanks
    Tagged:


Comments

  • Closed Accounts Posts: 7 bladez


    Should it not be "SELECT rollno,CASE"


  • Closed Accounts Posts: 38 PixelPixie


    Bless your eyes bladez!
    I never spotted the missing comma! In my defence, it's the first time I've tried this construction.
    bladez wrote: »
    Should it not be "SELECT rollno,CASE"


Advertisement