- UID
- 9878804
- 阅读权限
- 20
- 帖子
- 8
- 精华贴数
- 0
- 技术排名
- 99337
- 技术积分
- 14
- 社区排名
- 1454367
- 社区积分
- 0
- 注册时间
- 2007-5-15
- 精华贴数
- 0
- 技术积分
- 14
- 社区积分
- 0
- 注册时间
- 2007-5-15
- 论坛徽章:
- 0
|
发表于 2007-5-15 10:48:43
|显示全部楼层
create table tb1(id int,col1 varchar(10))
create table tb2(id int,col2 varchar(10))
insert tb1 select 1,'a'
union all select 2,'b'
union all select 3,'c'
union all select 4,'d'
insert tb2 select 1,'a'
union all select 1,'b'
union all select 2,'c'
union all select 2,'d'
union all select 3,'e'
union all select 3,'c'
union all select 3,'d'
union all select 1,'e'
union all select 4,'e'
select a1.id,col1,col2=(select max(col2) from tb2 where id=a1.id) from tb1 a1
drop table tb1,tb2
id col1 col2
----------- ---------- ----------
1 a e
2 b d
3 c e
4 d e |
|