Why you splitting up the table and making it so complicated?
Code:
table 1: ads
- a_id (PRIMARY)
- a_area
- a_code
- a_imp
- at_tid
- at_aid
- t_id (PRIMARY)
- t_name (Unique)
- t_category_name (INT(1), *INDEX)
// 1='sponsor1',2='big tits',3='milf',4='lisa ann',5='anal',6='default'
SELECT * from table a where t_category_name = 5 ORDER BY RAND() LIMIT 1