Invalid query:
SELECT n.id FROM news n JOIN news_has_category hc ON hc.news_id = n.id WHERE hc.category_id = '31316' AND n.status = 1