i need no fields omitted (do i still use *?) table 1 layout: id | otherrow | numeric 0 | anything | 1 table 2 layout: id | month | year 0 | 11 | 2009 i want to have this query for the amount of rows: SELECT COUNT(*) FROM `table2` WHERE `id` = `idfromtable1` AND `month` = '11' AND `year` = '2009'; Code (markup): table 1's query is like this: SELECT * FROM `table1` WHERE `otherrow` = 'anything' ORDER BY `numeric` DESC; Code (markup): i need to have the table 1 layout afterwards be: id | otherrow | numeric | tbl2count 0 | anything | 1 | 1 i've tried a lot things and nothing seemed to work.
isn't it strange how after you ask for help you finally get the result you are looking for? accomplished with: SELECT *,(SELECT COUNT(*) FROM `table2` WHERE `id` = `table1`.`id` AND `month` = '11' AND `year` = '2009') AS tbl2count FROM `table1` ORDER BY `tbl2count` DESC, `numeric` DESC Code (markup):