Menu

#1650 (in 2.6.3) SQL errors when ordering by count(*)

2.6.2-rc1
invalid
1
2013-06-11
2005-04-09
boxrec
No

This bug was reported before 988723 and supposedly
fixed. However it is still present in 2.6.2-rc1

SELECT count(*) , foo
FROM bar
GROUP BY foo

works fine, then if you click to sort on the count(*)
column you get the error

SELECT count( * ) , foo
FROM bar
GROUP BY foo
ORDER BY `count(*)` ASC

#1054 - Unknown column 'count(*)' in 'order clause'

This is caused by phpMyAdmin inserting extraneous
spaces either side of the wildcard, "SELECT count( *
)" should be "SELECT count(*)"

(or conversely if you must introduce extaneous spaces
put them into the ORDER BY subclause as well)

Discussion

  • Sven

    Sven - 2005-04-18

    Logged In: YES
    user_id=1261516

    same problem with some sql statements. sometimes pma inserts
    a space where it doesn't fit and then the sql query isn't
    valid. does anybody know which file to patch to not add
    extraneous spaces ?

     
  • Marc Delisle

    Marc Delisle - 2005-04-27
    • status: open --> open-fixed
     
  • Marc Delisle

    Marc Delisle - 2005-04-27

    Logged In: YES
    user_id=210714

    fixed in cvs.

    nologin: please give examples of such statements

     
  • Marc Delisle

    Marc Delisle - 2005-04-27
    • assigned_to: nobody --> lem9
    • priority: 5 --> 1
    • summary: SQL errors when ordering by count() --> (in 2.6.3) SQL errors when ordering by count()
     
  • boxrec

    boxrec - 2005-04-27

    Logged In: YES
    user_id=1256038

    2005-04-27 19:00 installed latest CVS and bug still present :-

    SQL query: Documentation
    SELECT foo( * ) , bar
    FROM mytable
    GROUP BY bar
    ORDER BY `foo(*)` ASC
    LIMIT 0 , 30

    MySQL said: Documentation
    #1054 - Unknown column 'count(*)' in 'order clause'

    boxrec

     
  • boxrec

    boxrec - 2005-04-27
    • priority: 1 --> 5
     
  • Marc Delisle

    Marc Delisle - 2005-04-27

    Logged In: YES
    user_id=210714

    Please confirm that you have libraries/sqlparser.lib.php v2.31.

     
  • boxrec

    boxrec - 2005-04-27

    Logged In: YES
    user_id=1256038

    No, latest cvs gave me :-
    /* $Id: sqlparser.lib.php,v 2.30 2005/04/25 19:43:55 lem9
    Exp $ */

     
  • Marc Delisle

    Marc Delisle - 2005-04-27

    Logged In: YES
    user_id=210714

    Ok, there is a 5-hour lag for anonymous cvs.
    I attached here the latest version, just unzip and rename
    to libraries/sqlparser.lib.php.

     
  • Marc Delisle

    Marc Delisle - 2005-04-27

    sqlparser.lib.php

     
  • boxrec

    boxrec - 2005-04-27

    Logged In: YES
    user_id=1256038

    You got it, good work.

    Many thanks, John boxrec.com

     
  • Marc Delisle

    Marc Delisle - 2005-04-28
    • priority: 5 --> 1
     
  • Sven

    Sven - 2005-04-28

    Logged In: YES
    user_id=1261516

    An example is if you have a statement like

    select a.* from atable a;

    sometimes will be modified by pma to

    select a. * from atable a; (extra space between . and *)

     
  • Marc Delisle

    Marc Delisle - 2005-07-03
    • status: open-fixed --> closed-fixed
     
  • Michal Čihař

    Michal Čihař - 2013-06-11
    • Status: closed-fixed --> invalid
     
MongoDB Logo MongoDB