0

I want to create a query like this

SELECT id, name, type, image FROM table ORDER BY type ASC, image.....

Pick up all type A rows first randomly, then list all type B rows randomly and all type C rows randomly. Within a same type, check if the row has image or not, then list rows with image randomly above rows without image.
The table has several thousand rows.
Any one has a good solution? Appreciate your help. Thanks

4

1 に答える 1

1
ORDER BY type ASC, CASE WHEN image IS NULL THEN 1 ELSE RAND() END ASC
于 2013-02-22T03:59:36.450 に答える