Hello, I am currently using UNION to join two tables for a query, however the problem is that I would like all of the results to be ordered based on a shared column. Basically, right now each Selection query is being ordered by a integer, however when they are combined, all of the order is mixed up. Here is my sql:
Code:
(SELECT title, description, author, featured, 'snippet' AS tablename FROM snippet WHERE featured > 0 ORDER BY `featured` LIMIT " . $p3['limit'] . ") UNION (SELECT title, description, author, featured, 'script' AS tablename FROM script WHERE featured > 0 ORDER BY `featured` LIMIT " . $p3['limit'] . ")
I cannot use array_sort in php because it goes through a while loop to display the results. Any suggestions?
Bookmarks