SQL UNION and ORDER BY
问题 I have an annoying SQL statement that seem simple but it looks awfull. I want the sql to return a resultset with userdata ordered so that a certain user is the first row in the resultset if that users emailaddress is in the companies table. I have this SQL that returns what i want but i think it looks awful: select 1 as o, * from Users u where companyid = 1 and email = (select email from companies where id=1) union select 2 as o, * from Users u where companyid = 1 and email <> (select email