文章已更新,最新地址:http://www.fearlazy.com/index.php/post/133.html
测试环境mysql5.7
现有测试表tb_books(数据库:testdatabase)
查询不重复的书名:
select distinct name from testdatabase.tb_books;
distinct可用于去除重复的记录,若distinct后跟两个字段则表示两个字段都相同才算重复。
select distinct name,price from testdatabase.tb_books;
此处只有name = 天空 并且price=88的才被过滤了。