CREATE VIEW v_contents_with_queries AS 
SELECT c.*, COUNT(q.user_id) AS total_queries
FROM contents AS c
LEFT JOIN queries AS q ON c.id = q.content_id
GROUP BY c.id
HAVING total_queries > 0