total of one column in other table

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
newbaba
Forum Newbie
Posts: 17
Joined: Thu Jan 26, 2017 10:36 pm
Location: Karachi

total of one column in other table

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: total of one column in other table

Post 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)
(#10850)
Post Reply