id name topid
1 aaa 0
2 bbb 0
3 ccc 1
4 ddd 1
5 eee 2
6 fff 2
这是数据表的格式,现在需要显示如下:
id name topname
3 ccc aaa
4 ddd aaa
5 eee bbb
6 fff bbb
sql语句改怎么写
1 aaa 0
2 bbb 0
3 ccc 1
4 ddd 1
5 eee 2
6 fff 2
这是数据表的格式,现在需要显示如下:
id name topname
3 ccc aaa
4 ddd aaa
5 eee bbb
6 fff bbb
sql语句改怎么写
解决方案 »
- SQL Server2008和SQL Server2008R2的区别,高手速进!
- 如何根据时间选择相应的行?
- sql2005异地自动备份问题(在线等)
- 跪求:MSSQL中维护计划和备份向导的区别???
- 在VB中我用access,下面的查询语句能正确执行,但升迁成SQL SERVER 2000后却报错。如何在SQL SERVER 2000也能实现下列语句的效果?select * from 书店 ORDER BY 类型='物理' , 类型='化学' ,
- 请教高手关于两表复杂查询统计更新字段问题
- SqlServer2008排序规则,哪个是UTF-8
- pdm格式的东东怎么导入sql数据库
- msslq 2005 大师,版主帮帮忙,增加了4G内存反而把CPU给搞挂了问题。
- 那位高人告诉我与Foxbase的total on 的SQL语句怎样写?
- Sql2005中创建备份作业启动失败!
- 新手求助:存储过程执行的问题
from tb a left join tb b on a.topid=b.id
where c.name is not null
create table tab6
(
tid int,
tname varchar(10),
topid int
)
insert into tab6
select 1,'aaa',0 union all
select 2,'bbb',0 union all
select 3,'ccc',1 union all
select 4,'ddd',1 union all
select 5,'eee',2 union all
select 6,'fff',2 select * from tab6select a.tid,a.tname,b.tname
from tab6 a,tab6 b
where a.topid=b.tidtid tname tname
----------- ---------- ----------
3 ccc aaa
4 ddd aaa
5 eee bbb
6 fff bbb(4 row(s) affected)