MySQL will be an alternative to a table of one another table

Functions to be achieved: The price listed salary table replace lost pay row shop table?

(The price list of commodities and commodity composition of a new table)

Table A: shop:
Here Insert Picture Description
Table B: salary:
Here Insert Picture Description

Solution:

Method one: create a new table, multi-table queries

create table Shopping_list(select id,type,product,shoper,orderdate,price from shop,salary where shop.id = salary.id1);

Method two: create a new table, the connector

create table Shopping_list(select id,type,product,price,shoper,orderdate from shop join salary on shop.id = salary.id1);

Method three: directly in the original table is updated, so that a full update to one another table

update shop1 set pay = (select price from salary where salary.id1 = shop1.id);

Renderings after implementation:

Here Insert Picture Description

Published 12 original articles · won praise 0 · Views 341

Guess you like

Origin blog.csdn.net/Junetest/article/details/104842202