0

我有两个表:食物 t1 和类别 t2 以及 t1 中称为“成分”的变量类别表包含类别列表,例如水果或蔬菜

即这是例如表2

ingredient | category
---------------------
apple | fruit 
broccoli | vegetable

我想对状态运行 UPDATE 查询

IE

更新集状态 = [ 来自 t2 的结果] 其中成分 = [ 来自 t2 的匹配成分]

因此,如果 t1 中的记录具有 'ingredient' = 'broccoli - 它会将状态变量设置为 'vegetable'

这个伪代码使用内连接、左连接的语法是什么?

4

2 回答 2

0

你的桌子的结构有点不清晰

Update table1
INNER JOIN table2 ON tabl1.ingredient  = taböe2.ingredient 
SET table1.status = table2.categories 
于 2021-08-29T23:37:36.237 回答
0
Update food t1
INNER JOIN categories t2 ON t1.ingredient  = t2.ingredient 
SET t1.status = t2.category
;
于 2021-08-30T00:22:15.210 回答