mysql新手需要幫助才能理解這一點想了解如何更新在mysql中的工作方式
SELECT * FROM roles1 r1;
result
id role
1 ROLE_SELLER1
1 ROLE_SELLER2
1 ROLE_SELLER3
2 ROLE_SELLER4
2 ROLE_SELLER5
SELECT * FROM roles r1;
result
id role
1 ROLE_SELLER1
2 ROLE_SELLER4
UPDATE roles1 r1,roles r SET r.role = r1.role WHERE r.id = r1.id;
後上面更新查詢角色表並不在all.i改變認爲它應該像
SELECT * FROM角色R1;
result
id role
1 ROLE_SELLER3
2 ROLE_SELLER5
SELECT r。 ,r1。 FROM roles r RIGHT JOIN roles1 r1 ON r.id = r1.id;
result
id role id role
1 ROLE_SELLER1 1 ROLE_SELLER1
1 ROLE_SELLER1 1 ROLE_SELLER2
1 ROLE_SELLER1 1 ROLE_SELLER3
2 ROLE_SELLER4 2 ROLE_SELLER4
2 ROLE_SELLER4 2 ROLE_SELLER5
更新角色r在r.id = r1.id上加入角色r1 set r.role = r1.role; 我想,當我用這個,應該更新角色表像進階
result
id role
1 ROLE_SELLER3 (last matched value from roles1 table id 1)
2 ROLE_SELLER5(last matched value from roles1 table id 1)
謝謝...
http://stackoverflow.com/questions/2334712/how-to-update-from-a-select-in-sql-server – drowned