Oracle 5.0 Reference Manual page 232

Table of Contents

Advertisement

Query OK, 0 rows affected (0.00 sec)
mysql>
SELECT owner, COUNT(*) FROM pet;
ERROR 1140 (42000): Mixing of GROUP columns (MIN(),MAX(),COUNT()...)
with no GROUP columns is illegal if there is no GROUP BY clause
• If
ONLY_FULL_GROUP_BY
single group, but the value selected for each named column is indeterminate. The server is free to
select the value from any row:
mysql>
SET sql_mode = '';
Query OK, 0 rows affected (0.00 sec)
mysql>
SELECT owner, COUNT(*) FROM pet;
+--------+----------+
| owner
+--------+----------+
| Harold |
+--------+----------+
1 row in set (0.00 sec)
See also
Section 12.15.3, "MySQL Extensions to
3.3.4.9. Using More Than one Table
The
table keeps track of which pets you have. If you want to record other information about them,
pet
such as events in their lives like visits to the vet or when litters are born, you need another table. What
should this table look like? It needs to contain the following information:
• The pet name so that you know which animal each event pertains to.
• A date so that you know when the event occurred.
• A field to describe the event.
• An event type field, if you want to be able to categorize events.
Given these considerations, the
mysql>
CREATE TABLE event (name VARCHAR(20), date DATE,
->
type VARCHAR(15), remark VARCHAR(255));
As with the
containing the following information.
name
Fluffy
Buffy
Buffy
Chirpy
Slim
Bowser
Fang
Fang
Claws
Whistler
Load the records like this:
mysql>
LOAD DATA LOCAL INFILE 'event.txt' INTO TABLE event;
Retrieving Information from a Table
[538]
| COUNT(*) |
8 |
CREATE TABLE
table, it is easiest to load the initial records by creating a tab-delimited text file
pet
date
1995-05-15
1993-06-23
1994-06-19
1999-03-21
1997-08-03
1991-10-12
1991-10-12
1998-08-28
1998-03-17
1998-12-09
is not enabled, the query is processed by treating all rows as a
GROUP
statement for the
type
litter
litter
litter
vet
vet
kennel
kennel
birthday
birthday
birthday
212
BY".
table might look like this:
event
remark
4 kittens, 3 female, 1 male
5 puppies, 2 female, 3 male
3 puppies, 3 female
needed beak straightened
broken rib
Gave him a new chew toy
Gave him a new flea collar
First birthday

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents