CREATE VIEW v_queries_pending AS
SELECT t.course_id, q.id AS question_id, q.content_id AS content_id, c.name AS content_name,
q.user_id AS user_id, u.name AS user_name, u.image AS user_image,
q.question AS question, q.description AS description, q.answered AS answered, q.created_at 
FROM queries AS q
JOIN contents AS c on c.id = q.content_id 
JOIN users AS u on u.id = q.user_id 
JOIN themes AS t on t.id = c.theme_id 
JOIN courses AS co on co.id = t.course_id 
WHERE q.answered = 0 and co.status = 1 
ORDER BY q.created_at DESC;