[root@kvm8 ~]# mysql -s -uroot -p123qwe mysql> use dyw; mysql>
mysql> show tables; Tables_in_dyw animals clone_animals dcount_tbl dyw_tbl person mysql>
mysql> select * from animals; id name foot 1 dog 4 2 cat 4 3 chicken 2
mysql> insert into animals(name,foot)
-> values('cat',4);
mysql> select * from animals; id name foot 1 dog 4 2 cat 4 3 chicken 2 4 cat 4 mysql>
SELECT COUNT(*) ... GROUP BY ... HAVING ... 語法計算重複紀錄。
mysql> select count(*) as repetitions, name,foot
-> from animals
-> group by name,foot
-> having repetitions >1;
repetitions name foot
2 cat 4
mysql>