wright67uk Posted May 13, 2013 Share Posted May 13, 2013 SELECT name FROM `races` WHERE `name` LIKE '$search%' GROUP BY NAME UNION SELECT horse_name FROM `notes` WHERE `horse_name` LIKE '$search%' GROUP BY horse_name"; Returns a single list of names that are sorted alphabetically per table ab - results of races ac - results of races ad - results of races ab - results of notes ac - results of notes ad - results of notes how can I change my query so that all of my results are sorted alphabetically as a whole? eg ab - results of races ab - results of notes ac - results of races ac - results of notes Quote Link to comment https://forums.phpfreaks.com/topic/277952-how-can-you-sort-union-results-as-a-single-table/ Share on other sites More sharing options...
Barand Posted May 13, 2013 Share Posted May 13, 2013 SELECT ... UNION SELECT ... ORDER BY name Quote Link to comment https://forums.phpfreaks.com/topic/277952-how-can-you-sort-union-results-as-a-single-table/#findComment-1429829 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.