sql+mysql 随机数据读取-进阶有关问题
Jun 13, 2016 pm 01:44 PM
sql+mysql 随机数据读取---进阶问题
比如有一个表 class , 里面的数据是一个花名册, 比如姓名,年龄,性别,籍贯
我现在想得到这么一个随机的结果: 按照籍贯,每个省份随机列出一条记录. 花名册里有的省份都要读取到.
请问这 SQL 语句该怎么写?
------解决方案--------------------
select m.* from (select * from user order by rand()) m group by m.area_id
user是你的表名,area_id是籍贯
问题解决。
如果对你有帮助,麻烦帮我点一下我网站的广告,谢谢。
网址:http://blog.72-web.com

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What is the difference between HQL and SQL in Hibernate framework?

Usage of division operation in Oracle SQL

What does the identity attribute in SQL mean?

Comparison and differences of SQL syntax between Oracle and DB2

Detailed explanation of the Set tag function in MyBatis dynamic SQL tags

How to use SQL statements for data aggregation and statistics in MySQL?

Database technology competition: What are the differences between Oracle and SQL?
