Page 1 of 1

total of one column in other table

Posted: Wed Aug 02, 2017 1:49 am
by newbaba
here is mysql query it is showing the desired result without any error but not updating the other table
my query is
SELECT count(*) as total_score,userdata.first_name,last_name,degree,email_address,nic,university,address,contact,company,age,gender FROM ans inner JOIN userdata on
ans.bio_id = 250 and userdata.bio_id =250
AND
ans.isCorrect = 1 UNION (UPDATE ANS WHERE bio_id=250)
i want to update the other table "result" from the total of ans
what is the correct way please guide me
any help will be much appreciated

Re: total of one column in other table

Posted: Wed Aug 02, 2017 11:58 pm
by Christopher
You said update, which might be more complicated. If the query below has the same columns are the table result, then you can do:
INSERT INTO result SELECT count(*) as total_score,userdata.first_name,last_name,degree,email_address,nic,university,address,contact,company,age,gender FROM ans inner JOIN userdata on
ans.bio_id = 250 and userdata.bio_id =250
AND
ans.isCorrect = 1 UNION (UPDATE ANS WHERE bio_id=250)