我有两张 table
Table TblParts
(id
detail
code
stock)
Table TblExistencias
(code
Serial)
我需要进行查询以使用 TblExistencias
表(计数代码)升级 TblParts.stock
。
if TblExistencias.code = TblParts.code then Count(TblExistencias.code) and update TblParts.stock
我怎样才能做到?
最佳答案
你应该做这样的事情。 使用子查询更新语句
update TblParts set stock= COALESCE((select count(*) from TblExistencias where
TblExistencias.code = TblParts.code),0)
关于mysql 查询两个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49582522/