I have a problem. I receive this error:

Database error: Invalid SQL: select b.id as category, a.id as link, a.*, 1*(a.showt-a.showc)+ #total search 1*(a.showc) + #total in category 3*(a.hit) as criteria2 from links a right join link_categories b where (category,link,criteria2) in ( select b.id as category, a.id as link, 1*(a.showt-a.showc)+ #total search 1*(a.showc) + #total in category 3*(a.hit) as criteria from links a right join link_categories b on b.id=a.category_id where To_Days(Now()) - TO_Days(a.ldate) > 7 order by criteria asc limit 0, 5) order by criteria2 desc;
MySQL Error: 1064 (You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'where (category,link,criteria2) in ( select b.id as categ)

The SQL statement is:

select b.id as category, a.id as link, a.*,
1*(a.showt-a.showc)+ #total search
1*(a.showc) + #total in category
3*(a.hit)
as criteria2
from links a right join link_categories b
where (category,link,criteria2) in (
select b.id as category, a.id as link,
1*(a.showt-a.showc)+ #total search
1*(a.showc) + #total in category
3*(a.hit)
as criteria
from links a right join link_categories b
on b.id=a.category_id
where To_Days(Now()) - TO_Days(a.ldate) > 7

order by criteria asc
limit 0, 5)
order by criteria2 desc;