I have some table restore user articles. the table struction like…
id | uid | imgae |
1 | 1 | 1.jpg |
2 | 1 | |
3 | 2 | 2.jpg |
4 | 3 | 3.jpg |
5 | 3 | |
6 | 3 | 4.jpg |
7 | 4 | |
...
Then I want get 10 result witch image!=''
(select * from my_table where image!='' order by rand() limit 1)
UNION
(select * from my_table where image!='' order by rand() limit 1)
UNION
(select * from my_table where image!='' order by rand() limit 1)
UNION
(select * from my_table where image!='' order by rand() limit 1)
UNION
(select * from my_table where image!='' order by rand() limit 1)
UNION
(select * from my_table where image!='' order by rand() limit 1)
UNION
(select * from my_table where image!='' order by rand() limit 1)
UNION
(select * from my_table where image!='' order by rand() limit 1)
UNION
(select * from my_table where image!='' order by rand() limit 1)
UNION
(select * from my_table where image!='' order by rand() limit 1)
And how to make a further query. 10 result with 10 different uid (a.uid!=b.uid)? And the code is too long… Any easy way? Thanks.
Change the limit and include a group by :