What you can do is combine the two results, sort by the most important, and then limit the Union:
SELECT Col1, Col2, ... FROM ( SELECT Col1, Col2, `read`, ... FROM notifications WHERE read = 0 UNION SELECT Col1, Col2, `read`, ... FROM notifications WHERE read = 1 ) x ORDER BY x.`read`
SqlFiddle here
Edit, Re: Must return ALL Unread, not just the first 10
Sorry, I skipped this part of the question. I canβt come up with an elegant way to achieve this, therefore here is a partial solution that resorts to an imperative procedure and a temporary table to fill in the rows if necessary: use codingbiz solution until MySql supports Windowing functions (e.g. ROW_NUMBER() OVER (PARTITION BY read ORDER BY Col1 DESC)
source share