文章表
从随机栏目下随机取几条符合条件的记录
求高效写法
数据库是mysql的,但是没人回答,到这边试试
从随机栏目下随机取几条符合条件的记录
求高效写法
数据库是mysql的,但是没人回答,到这边试试
解决方案 »
- Sql Server主键与外键的关系?
- 求迟到次数最多的员工的最后一次的迟到时间
- sql server 2005怎么恢复的,用代码怎么写,很急的!!谢谢大家!!!
- 如何把--------5转为1+2+3+4+5的和?
- 我的系统是windows2003别人如何开启telnet服务?
- 跪求sql server 2005附加数据库时提示"附加数据库时出错。有关详细信息,请单击“消息”列中的超链接"!!的解决方法
- sql日期函数
- update链接服务器数据时出错?
- 如果写的SQl函数返回的字符大于4000个字符该怎么办?
- 问一个关于DTS的问题 , 感觉比较棘手 , 还望大家指点一下
- 求助,谢谢
- SQL重复数据只显示一条,查询语句怎么写
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.5.17 MySQL Community Server (GPL)Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trade of Oracle Corporation and/or its
affiliates. Other names may be trades of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> use test1;
Database changed
mysql> SELECT * FROM user ORDER BY rand() LIMIT 5;
+------+------+
| id | name |
+------+------+
| 2 | joe |
| 5 | ggg |
| 6 | vvcc |
| 6 | vvvv |
| NULL | cccc |
+------+------+
5 rows in set (0.00 sec)mysql>
a.*
from
`user` as a
where
(select count(1) from `user` where name >= a.name and id=a.id) <=2
order by
rand();