Thanks, Andy - I repaired the tables and the message said that it repaired one of the categories which had 205 links and now it has 202 or something like that. After that, I first tried again with that original global get_links_from_related_cats and still showed the same errors. Then I posted your new code in the global - good news is that it no longer shows that MySql error anymore for the same categories where it showed the error earlier but now what - how do I get it to show the related links? Thanks!