Hi people,
I wasn't sure where to post this, it's a specific SQL syntax type problem, and didn't know where it should go. Sorry if there's a better place for it!
I want to update table 'Pupils' with some data from table 'TempAttendance'. I have an id number in the temp table that matches up with the pupil's id number in the proper 'Pupils' table.
I've tried loads, but I'm struggling!
So I want to update table Pupils.attendance with the value from TempAttendance.attendance where the ID = the ID. I can't get the syntax right. Pleas help if you can!
Thanks
update pupils set attendance = (select attendance from TempAttendance where pupils.ID = TempAttendance.ID);
May sure you get only 1 record for each pupil.ID = TempAttendance.ID.
|||s_kushal answer is my answer.Plz check out
Thank u
Baba
Please remember to click "Mark as Answer" on this post if it helped you.
|||thanks for the efforts guys but I worked it out before this was moderated and posted!
kushal I already tried that and it didn't work.
This is what worked:
UPDATE tbl_pupils
SET ppl_attendance =
(SELECT Attendance
FROM dataget.TempAttendance
WHERE dataget.TempAttendance.adno = tbl_pupils.ppl_adno)
WHERE EXISTS
(SELECT Attendance
FROM dataget.TempAttendance
WHERE dataget.TempAttendance.adno = tbl_pupils.ppl_adno)
Thanks for helping anyway
No comments:
Post a Comment