有15个tables ,column都是一样的 id , images 想从15个tables 中 随机输出15条数据 ,指定一个 table 只能一条数据. 简单说就是去table1 随机拿一条,再去table2 随机一条,以此类推 ... 语句该怎么写呢?
解决方案 »
- MySQL密码忘记了,求改密!
- 查询语句求解
- mysqldump如何导出部分字段的部分数据
- (求教,急~~~)一个表中,不同字段,相同的值,汇总的方法
- 如何在每天零点,MYSQL自动对各条记录的截至日期进行比较,若超过,则对该记录进行标识
- MYSQL使用UTF8的字符集,如何对中文进行拼音排序啊?
- PostgreSQL 存储过程的问题?
- mssql调试正常,mysql为什么报错!!!
- 求判断存储过程这么写是否正确.
- centos mysql出错导致服务器关闭
- 存储过程中,运行出现Column count doesn't match value count at row 1问题。麻烦大大帮忙解决
- mysql数据库触发器问题
union all
select * from tb1 where id=rand()
...
union all
select * from (SELECT * from table2 ORDER BY RAND() LIMIT 1) b
类似这样会好吗 ?
union all
select * from table2 where order by rand() limit 1
union all
.....
union all
(select * from table2 order by rand() limit 1 )
union all
(select * from table3 order by rand() limit 1 )
union all
(select * from table4 order by rand() limit 1 )
union all
(select * from table5 order by rand() limit 1 )
union all
(select * from table6 order by rand() limit 1 )
union all
(select * from table7 order by rand() limit 1 )
union all
(select * from table8 order by rand() limit 1 )
union all
(select * from table9 order by rand() limit 1 )
union all
(select * from table10 order by rand() limit 1)
union all
(select * from table11 order by rand() limit 1)
union all
(select * from table12 order by rand() limit 1)
union all
(select * from table13 order by rand() limit 1)
union all
(select * from table14 order by rand() limit 1)
union all
(select * from table15 order by rand() limit 1)