假設有桌子表名 icate_table_set(table_id,table_name,table_state_id,store_id), 桌子狀態表名icate_table_state(state_id,state_name,state_attr狀態屬性如空桌,使用中等,store_id)
store_id假設是分店ID 各分店的狀態名可能一樣可能不一樣但是屬性是一樣的
現在要把所有桌子改為對應如空桌狀態(1為空桌)
UPDATE icate_table_set
SET table_state_id=(SELECT state_id FROM icate_table_state WHERE state_attr='1' AND store_id=a.store_id)
from icate_table_set a,icate_table_state b
