mart94 Posted October 17, 2010 Share Posted October 17, 2010 Hi! I created query: $query = mysql_query("SELECT row, COUNT(*) AS rowCount FROM table1 WHERE row2 = 'something' GROUP BY row ORDER BY rowCount DESC"); What it does, it querys from database, and gives me something like TOP style, i mean, it Orders by rowCount, and it is working well, but now, i need little bit help, I want to take that Count from talbe2 also. And then Order by total count. Hope you understand! All The Best, Mart Link to comment https://forums.phpfreaks.com/topic/216071-mysql-query-order-by-count/ Share on other sites More sharing options...
fenway Posted October 17, 2010 Share Posted October 17, 2010 No, I don't. Link to comment https://forums.phpfreaks.com/topic/216071-mysql-query-order-by-count/#findComment-1122987 Share on other sites More sharing options...
mart94 Posted October 17, 2010 Author Share Posted October 17, 2010 No, I don't. I need query, witch counts from 2 different table "row" values, and orders by count total. Example: I have a table named T1, and it includes: 1 1 2 2 3 3 4 4 5 5 and another table named T2: 1 1 2 2 3 3 4 4 5 5 Now, query counts both values: 1 2 2 4 4 6 5 10 Now it orders it Desc 5 10 4 6 2 4 1 2 Table content can be also: 1 2 1 3 1 4 2 4 5 6 And second: 1 4 1 2 2 5 4 1 5 2 Counting result: 1 15 2 9 4 1 5 8 Ordering: 1 15 2 9 5 8 4 1 Link to comment https://forums.phpfreaks.com/topic/216071-mysql-query-order-by-count/#findComment-1122993 Share on other sites More sharing options...
fenway Posted October 17, 2010 Share Posted October 17, 2010 You're using COUNT and SUM interchangeably. Link to comment https://forums.phpfreaks.com/topic/216071-mysql-query-order-by-count/#findComment-1122996 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.