1.查询重复数据
查询test表中A列值为100的时候B列重复的数据,例如:
A B C D
100 hz
100 lh
100 hz
那么显示B为hz的行
2011-01-01 a
2011-01-02 b
2011-01-02 b
显示结果为
A B
2011-01-01 2
2011-01-02 2
select A ,count(*) from (select * from test group by A,B) test group by A
先通过select * from test group by A,B去重复再进行分组计算
或者可以使用select count(dinstinct B) from test group by A
3.mysql设置列唯一性
create unique index column_index on table(column)
4.mysql insert忽略错误
insert ignore into tb(...) value(...)
5.mysql查看表创建语句
mysql> show create table tb
6.mysql查看列的详细信息
mysql> show full columns from tb
7.mysql查看字符集
mysql> show variables like '%char%'
8.mysql设置连接字符集
set names gb2312;