开发者

How to extract random entries from multiple mysql tables directly from database?

I am trying to extract a maximum of 5 ent开发者_StackOverflowries randomly from two tables combined directly from database.

kinda like this SELECT RANDOM FROM table1,table2 LIMIT 0,5)

I am aware that I can filter the result later on from PHP, but I want only 5 random rows from database.

These multiple tables might have different database structure


Have you considered something like

(SELECT * from table1) union (select * from table2) order by rand() limit 0,5
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜