时间:2021-07-01 10:21:17 帮助过:11人阅读
create table m(
id int ,
zid int ,
kid int ,
res varchar (10),
mtime date
) charset utf8;
insert into m values
(1,1,2, ‘2:0‘ , ‘2006-05-21‘ ),
(2,3,2, ‘2:1‘ , ‘2006-06-21‘ ),
(3,1,3, ‘2:2‘ , ‘2006-06-11‘ ),
(4,2,1, ‘2:4‘ , ‘2006-07-01‘ );
create table t
(tid int ,tname varchar (10)) charset utf8;
insert into t values
(1, ‘申花‘ ),
(2, ‘红牛‘ ),
(3, ‘火箭‘ );
|
要求按下面样式打印2006-0601至2006-07-01期间的比赛结果 样式: 火箭 2:0 红牛 2006-06-11 查询语句为: select zid,t1.tname as t1name,res,kid,t2.tname as t2name,mtime from m left join t as t1 on m.zid = t1.tid left join t as t2 on m.kid = t2.tid where mtime between ‘2006-06-01‘ and ‘2006-07-01‘; 总结:可以对同一张表连接多次,以分别取多次数据
mysql的查询、子查询及连接查询
标签:库存 word 算术 alt lin 限制 品牌 聚合函数 esc