Umm... don't you need a JOIN in there somewhere?
-----Original Message-----
the best way is to let the database do all the work
select category, subcat
from tableA, tableB
where tableB.categoryID = tableA.categoryID
order by category, subcat