Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT q_a_d.*, node.created AS created, q_a_b.num
- FROM poll_questions_answers_data AS q_a_d
- RIGHT JOIN poll_node AS node ON q_a_d.nid = node.nid
- LEFT JOIN (
- SELECT q_a_s.qasid AS qasid, q_a_s.qbid AS qbid, q_a_s.nid AS nid, @num:=@num+1 num
- FROM poll_questions_answers_storage AS q_a_s, (select @num:=0) x
- WHERE q_a_s.uid = :uid AND q_a_s.status = 1
- ORDER BY q_a_s.qasid DESC
- LIMIT 2
- ) AS q_a_s_clone ON q_a_s_clone.nid = q_a_d.nid
- 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) )
- WHERE q_a_d.uid = :uid
- ORDER BY q_a_d.qadid DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement