Welcome to WebmasterWorld Guest from 54.224.230.193

Forum Moderators: open

Message Too Old, No Replies

sort by numrows ?

     
10:27 am on Feb 28, 2009 (gmt 0)

New User

5+ Year Member

joined:Feb 26, 2009
posts:15
votes: 0


is there any way to sort mysql results by number of rows example
i have two tables
--
one
id
title
data
--

--
two
id
title
--

now both table have the same data in title

example
(table1)title=ex1
(table1)title=ex2
----
(table2)title=ex1
(table2)title=ex1
(table2)title=ex2
----

now i want to do is searching the table one with the title ex1
with like %ex%

the result should show the both ex1 and ex2
and i want to sort them with the numrows i get from table2.
DESC, so the ex1 should be 1st and ex2 2nd any idea ?

10:48 pm on Mar 13, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12541
votes: 1


I believe you should be able to GROUP BY title and ORDER BY a COUNT in DESC order