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
精彩评论