These are my tables:
tbl_answers =>
aid
qid
answer
uid
dateposted
emailnotify
namedisplay
status
isbestanswer
tbl_questions =>
qid
question
detail
mcid
cid
uid
answercount
dateposted
status
showname
emailnotify
question_type_id
I tried this:
UPDATE tbl_questions
JOIN (
SELECT id, COUNT(*) AS n
FROM tbl_questions JOIN tbl_answers ON qid = tbl_questions.qid
WHERE answercount = "0"
GROUP BY id
) AS T USING (id)
SET num = n
WHERE n > 0
I woud like to update those question that has got more answers than it's counted in:
tbl_questions => answercount
How can I update the rows which have got more questions than it's counted? (Without php loop)