Sunday, July 28, 2013

add a data to table from another table with sum function

hello everyone.


İ have 2 tables calisanlar and Siparis_onaylanan.In calisanlar table there are calisan_no,adet and etc. columns.In Siparis_onaylanan table there are Siparis_id,urun,adet,calisan_no and etc. columns.I want to add data adet in calisanlar from sum(adet) Siparis_onaylanan.


For example


Caner Ünver's calisan_no(worker_id) 147 and add a delivery 5 banana and 4 watermelon.I want to add this numbers of items to calisanlar's adet


i wanna codes like that


update calisanlar set adet=select sum(adet) from Siparis_onaylanan where Siparis_onaylanan.calisan_no=calisanlar.calisan_no


but it doesn't work :)


No comments:

Post a Comment