Oracle 5.0 Reference Manual page 990

Table of Contents

Advertisement

This function returns
[970]
COUNT(expr)
Returns a count of the number of
statement. The result is a
[970]
returns
COUNT()
mysql>
SELECT student.student_name,COUNT(*)
->
FROM student,course
->
WHERE student.student_id=course.student_id
->
GROUP BY student_name;
[970]
is somewhat different in that it returns a count of the number of rows retrieved,
COUNT(*)
whether or not they contain
[970]
is optimized to return very quickly if the
COUNT(*)
columns are retrieved, and there is no
mysql>
SELECT COUNT(*) FROM student;
This optimization applies only to
this storage engine and can be accessed very quickly. For transactional storage engines such as
and BDB, storing an exact row count is more problematic because multiple transactions may
InnoDB
be occurring, each of which may affect the count.
COUNT(DISTINCT expr,[expr...])
Returns a count of the number of rows with different
COUNT(DISTINCT)
mysql>
SELECT COUNT(DISTINCT results) FROM student;
In MySQL, you can obtain the number of distinct expression combinations that do not contain
by giving a list of expressions. In standard SQL, you would have to do a concatenation of all
NULL
expressions inside
COUNT(DISTINCT ...)
GROUP_CONCAT(expr)
This function returns a string result with the concatenated
if there are no
NULL
GROUP_CONCAT([DISTINCT]
[ORDER BY
[ASC | DESC]
[SEPARATOR str_val])
mysql>
SELECT student_name,
->
GROUP_CONCAT(test_score)
->
FROM student
->
GROUP BY student_name;
Or:
mysql>
SELECT student_name,
->
GROUP_CONCAT(DISTINCT test_score
->
->
FROM student
->
GROUP BY student_name;
In MySQL, you can get the concatenated values of expression combinations. To eliminate duplicate
values, use the
DISTINCT
(Aggregate) Functions
GROUP BY
if there were no matching rows.
0
non-NULL
value.
BIGINT
if there were no matching rows.
0
values.
NULL
WHERE
tables only, because an exact row count is stored for
MyISAM
[970]
[970]
returns
if there were no matching rows.
0
[970]
non-NULL
values. The full syntax is as follows:
expr [,expr
...]
{unsigned_integer
[,col_name
ORDER BY test_score DESC SEPARATOR ' ')
clause. To sort values in the result, use the
970
values of
in the rows retrieved by a
expr
retrieves from one table, no other
SELECT
clause. For example:
non-NULL expr
[970].
non-NULL
|
col_name
| expr}
...]]
SELECT
values.
values from a group. It returns
clause. To sort in
ORDER BY

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents