Friday, 23 August 2013

How could I simplify this query?

How could I simplify this query? References How can this function be better? I feel there might be a more elegant way of doing it. For a little background on the function. I am trying to evaluate if someone has read and seen all the questions of a book. \"SELECT COUNT(s.id), (SELECT COUNT(u.id) FROM user_sections u WHERE u.chpt_id = ? && u.user_id = ?), (SELECT COUNT(q.id) FROM question q WHERE q.chapter_id = ? && (q.module = 1 || q.module = ?)), (SELECT COUNT(v.id) FROM user_questions v WHERE v.chpt_id = ? && u.user_id = ?), (SELECT AVG(v.box) FROM user_questions v WHERE v.chapter_id = ? && u.user_id=?), (SELECT AVG(m.$mkts_col) FROM mkts m WHERE m.chapter_id = ? && (m.module = 1 || m.module = ?)) FROM sections s WHERE s.chapter_id = ? && (s.module = 1 || s.module = ?)\");

No comments:

Post a Comment