Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.74 KB | None | 0 0
  1. SELECT q_a_d.*, node.created AS created, q_a_b.num
  2.         FROM poll_questions_answers_data AS q_a_d
  3.         RIGHT JOIN poll_node AS node ON q_a_d.nid = node.nid
  4.         LEFT JOIN (
  5.             SELECT q_a_s.qasid AS qasid, q_a_s.qbid AS qbid, q_a_s.nid AS nid, @num:=@num+1 num
  6.             FROM poll_questions_answers_storage AS q_a_s, (select @num:=0) x
  7.             WHERE q_a_s.uid = :uid AND q_a_s.status = 1
  8.             ORDER BY q_a_s.qasid DESC
  9.             LIMIT 2
  10.         ) AS q_a_s_clone ON q_a_s_clone.nid = q_a_d.nid
  11.         LEFT JOIN poll_questions_base AS q_a_b ON q_a_s_clone.qbid = q_a_b.qbid and ( (q_a_d.status = 1 and num = 2) or (q_a_d.status != 1 and num = 1) )
  12.         WHERE q_a_d.uid = :uid
  13.         ORDER BY q_a_d.qadid DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement