我有以下搜索和选择2个表
SELECT table_a.*, table_b.*
FROM table_a
LEFT JOIN table_b ON table_a.visitorBarcode = table_b.business_barcode
WHERE table_a.visitorBarcode LIKE '00996689' OR table_b.business_barcode LIKE '00996689'
现在条形码值(即00996689)可以在table_a或table_b中找到,我喜欢更新特定表中的特定列。这些是我用于个人更新的查询
UPDATE table_a SET entered = '1' WHERE visitorBarcode = '00996689';
UPDATE table_b SET entered = '1' WHERE business_barcode = '00996689';
但是如何在这两个查询之间切换?
答案 0 :(得分:2)
我认为没有必要组合这些查询,但你可以这样做:
UPDATE table_a a JOIN table_b b ON a.visitorBarcode = b.business_barcode
SET a.entered = '1',
b.entered = '1'
WHERE a.visitorBarcode = '00996689';