我有两个表buffer_details和stock。我想用缓冲区明细表中的数据更新库存表。
CREATE TABLE `buffer_details` ( `Ref` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `Reference_produit` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `Qte` decimal(10,2) NOT NULL, PRIMARY KEY (`Reference_produit`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=COMPACT;
CREATE TABLE `stock` (`Reference` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `qte` decimal(10,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`Reference`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
我尝试了此方法,但是它不起作用,我正在使用Mysql。请注意,它是Qte = Qte +(buffer_details.Qte)
Update (select * from buffer_details) AS D1,stock set stock.qte = stock.qte + D1.Qte WHERE stock.Reference = D1.Reference_produit
答案 0 :(得分:0)
您可以使用update-join语法:
list_requests = CategoryRequests.objects.filter(status='Waiting')
list_requests = CategoryRequests.objects.get_queryset().order_by('-pk')