Assuming that the field "category" in the table "items" corresponds to the field "id" in the table "category" and you want to solve this using SQL instead of Perl and you are using Mysql (may work on other databases as well, but untested) ...
which is a lot of assumtions :^)
You could use
SELECT items.* FROM items, category WHERE items.category = category.id
+ ORDER BY items.id DESC LIMIT 2;
If you are going to be doing a bit of database driven programming, it's certainly worth your time to spend a bit of time studying SQL. I'm just beginning to realize its power for certain tasks.
--
dug