SQL语句。。。。。。。。。。 UserID UserName Age MID102 小名 29 106104 小王 28 106106 小红 27 108107 小时 25 MID是UserName的主管的ID,请查出年龄比主管大的UserID,UserName谢谢各位。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 trySelect A.UserID, A.UserNameFrom TableName AInner Join TableName BOn A.MID = B.UserIDWhere A.Age > IsNull(B.Age, 0) Select * from 表 as twhere exists(Select * from 表 where t.Mid=UserID and t.Age>Age) 要精通SQL语句有什么好书吗,推荐一下啊,各位朋友 create table #(UserID varchar(3),UserName varchar(10),Age int,MID varchar(3))insert into #select '102' , '小名' , 29 , '106'union all select '104' , '小王' , 28 , '106'union all select '106' , '小红' , 27 , '108'union all select '107' , '小时' , 25 ,'104'select * from #select a.*,b.*from # a left join # b on (a.mid=b.userid)where a.age>b.age==================UserID,UserName,Age,MID102,小名,29,106104,小王,28,106106,小红,27,108107,小时,25,104(所影响的行数为 4 行)UserID,UserName,Age,MID,UserID,UserName,Age,MID104,小王,28,106,106,小红,27,108102,小名,29,106,106,小红,27,108(所影响的行数为 2 行) 在一个应用程序里用多个数据库有哪些优点? 一张表排序问题 问一个判断空的sql语句 请问各位大侠 SQL语句中怎么修改一个字段不能为空? MS SQL 2000字段拆分 如何用SQL语句实现两张表(无关联)查询后,分别将各自的一个字段,插入一个新表 sql server management studio 在"关系图"窗格和"条件"窗格中无法用图形方法表示查询 一个简单SQL,但是就是想不明白 用什么语句来判断表中某个字段已存在??????? RollBack语句引起的数据丢失如何恢复 很简单一个SQL语句 见笑了! 求一SQL语句
A.UserID,
A.UserName
From
TableName A
Inner Join
TableName B
On A.MID = B.UserID
Where A.Age > IsNull(B.Age, 0)
where exists(Select * from 表 where t.Mid=UserID and t.Age>Age)
(
UserID varchar(3),
UserName varchar(10),
Age int,
MID varchar(3)
)insert into #
select '102' , '小名' , 29 , '106'
union all select '104' , '小王' , 28 , '106'
union all select '106' , '小红' , 27 , '108'
union all select '107' , '小时' , 25 ,'104'
select * from #select a.*,b.*
from # a left join # b on (a.mid=b.userid)
where a.age>b.age==================
UserID,UserName,Age,MID
102,小名,29,106
104,小王,28,106
106,小红,27,108
107,小时,25,104(所影响的行数为 4 行)UserID,UserName,Age,MID,UserID,UserName,Age,MID
104,小王,28,106,106,小红,27,108
102,小名,29,106,106,小红,27,108(所影响的行数为 2 行)