Professional Web Applications Themes

Simple newbie COUNT question - MySQL

How do I get the results of a SELECT, and count the results at the same time? I've tried: SELECT productname, COUNT(*) AS cnt from URL but this gives: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause Help!...

  1. #1

    Default Simple newbie COUNT question

    How do I get the results of a SELECT, and count the results at the
    same time?

    I've tried:

    SELECT productname, COUNT(*) AS cnt from URL

    but this gives:
    Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP
    columns is illegal if there is no GROUP BY clause

    Help!

    lister Guest

  2. #2

    Default Re: Simple newbie COUNT question

    lister schrieb: 

    You need to add a "group by " to your statement (like the error message
    tells you).
    Philip Guest

  3. #3

    Default Re: Simple newbie COUNT question

    > You need to add a "group by " to your statement (like the error message 

    But I don't want it grouped by anything. I just want the normal result
    set.


    lister Guest

  4. #4

    Default Re: Simple newbie COUNT question

    lister wrote: 
    >
    > But I don't want it grouped by anything. I just want the normal result
    > set.
    >
    >[/ref]
    that will be the normal result set. for mysql to calculate the count it
    needs to group by the column you're selecting so something like this
    will do it for you:

    SELECT productname, COUNT(*) AS cnt from URL group by productname

    --
    lark -- net
    To reply to me directly, delete "despam".
    lark Guest

  5. #5

    Default Re: Simple newbie COUNT question

    On May 3, 3:20 am, lister <com> wrote: 

    Can't do it in one command. Mysql has a command that lets you get the
    number of results served in the last query, but I don't remember what
    it is. Your programming language of choice might offer up an easy
    way to accomplish what you're after though.

    Aerik


    Aerik Guest

Similar Threads

  1. simple newbie question
    By George in forum Macromedia Flash
    Replies: 2
    Last Post: June 18th, 01:45 PM
  2. SIMPLE Question! - Count <cfloop>
    By sams@centric.net in forum Macromedia ColdFusion
    Replies: 0
    Last Post: April 4th, 06:42 PM
  3. Simple Question for a newbie
    By RES in forum Macromedia Flash
    Replies: 1
    Last Post: July 28th, 10:40 AM
  4. newbie question on count()
    By Karzy in forum PHP Development
    Replies: 3
    Last Post: September 18th, 07:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139