You may want to use GROUP BY clause to get a count of the results .. See:
http://www.mysql.com/doc/G/r/Group_by_functions.html

For example, to retrieve the number of row where nation is "German" do:
SELECT COUNT(*) AS mycount, nation FROM memberscopy WHERE nation='German'
GROUP BY nation;

Gurhan

-----Original Message-----
From: Sven Bentlage [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 07, 2002 12:00 AM
To: [EMAIL PROTECTED]
Subject: newbie question:count() and display details


Hi
I have a (probably fairly simple newbie question:

Using a select statement (via DBI) I get some details from a table and
at the same time have a row count of how many rows are returned (to be
displayed at the website).
  A query like

                select count(nation) AS nation, name, nation from memberscopy
where nation = "Austrian"               order by course;

results in the following error:
                ERROR: Query failed (Mixing of GROUP columns
(MIN(),MAX(),COUNT()...) with no GROUP columns is               illegal if there
is no GROUP BY clause)

If I use :
                select count(*) AS nation, name, nation from memberscopy where
nation = "German"  group by             surname         order by course ;

I get those details
                                | nation | name            | nation   |
                                |      1 | Christian       | Austrian |
                                |      1 | Christian       | Austrian |
                                |      1 | Maximilian      | Austrian |
                                |      1 | Edgar Alexander | Austrian |
                                |      1 | Erik            | Austrian |
                                |      1 | Maria           | Austrian |

Is there any way that I can get a line count of the result set and the
details with onl one query?

Thanks for your help!

Sven


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to