要实现的功能:将salary表中的price列替代掉shop表中的pay列?
(把商品的价格与商品列表组成一个新表)
表A:shop:
表B:salary:
解决方法:
方法一: 创建一张新表,多表查询
create table Shopping_list(select id,type,product,shoper,orderdate,price from shop,salary where shop.id = salary.id1);
方法二: 创建一张新表,内连接
create table Shopping_list(select id,type,product,price,shoper,orderdate from shop join salary on shop.id = salary.id1);
方法三: 直接在原表更新,让一列完全更新成另一个表中的一列
update shop1 set pay = (select price from salary where salary.id1 = shop1.id);