Is it possible to order the first enquiry and keep the rows returned as first and not order the second enquiry. (If that makes sence)
An example of my current enquiry is :
SELECT
*
FROM
Devices
WHERE
Live = 'true'
AND Category = 'apple'
ORDER BY
ListOrder
UNION
SELECT
*
FROM
Devices
WHERE
DeviceLive = 'true'
I was hoping that the devices under the category apple would be organised in there list order and would be at the top of the list above the other devices. But this seems to jumble the two querys together.
You'd need to introduce an artificial sort key. Something like:
SELECT
*, 1 as SortKey
FROM
Devices
WHERE
Live = 'true'
AND Category = 'apple'
UNION
SELECT
*, 2 as SortKey
FROM
Devices
WHERE
DeviceLive = 'true'
ORDER BY SortKey, ListOrder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With