Hi all,
I am trying to write a query which does the following.
- There are two queries which gets results in random from two tables using UNION
This is how it looks like
(select i from tbl1)
UNION
(select i from tbl2)
ORDER BY RAND()
I want this result set to be random. But before displaying the results from these tables I want to display another set of results from table 3 which would be displayed first and then followed by the random results SET.
So I tried using like the following
(select tbl3.i from tbl3 LIMIT 3)
UNION
(
(select tbl1.i from tbl1)
UNION
(select tbl2.i from tbl2)
ORDER BY RAND()
)
I get an error. The problem comes when I am nesting the queries. I want the first query to execute first and then the second query which would display results in random from the two queries.
Is the above senario possible…
Here is an example on how I want it to work…
I want t3.1 results to be displayed first and then followed by combination of resuts from tbl1 and tbl2.
Thank you in advance.