MySQL JOIN语句 - 空宝网


MySQL JOIN语句

create table product_name (
id smallint,
productname varchar(10)
);

create table exchange_history (
id smallint,
exchangeFrom smallint,
exchangeTo smallint
);

insert into product_name values (1, ‘item 1’);
insert into product_name values (2, ‘item 2’);
insert into product_name values (3, ‘item 3’);

insert into exchange_history values (1,1,3);
insert into exchange_history values (2,3,2);
insert into exchange_history values (3,2,1);

select h.id,
p.productname as exchangeFrom,
p1.productname as exchangeTo
from exchange_history h
join product_name p
on h.exchangeFrom = p.id
join product_name p1
on h.exchangeTo = p1.id

下一页:  如何更改Windows DFS复制日志文件路径?

喜欢 (0)
[请支持作者一杯咖啡,谢谢]
分享 (0)


您必须 登录 才能发表评论!