--插入数据
--insert QQUser (QQID, PassWord, LastLogTime, Online, Level)
--select 54789625,'add512#&','2013-02-16 17:01:35',2,1 Union
--select 88662753,'admin0219','2013-02-19 21:08:50',0,5 Union
--select 8855678,'guest0221','2013-02-21 16:28:20',1,6
--select * from QQUser
--insert into BaseInfo
--select 8855678,'双眼皮猪',1,38,'北京市','北京','双榆树东里','65794968876143'
--select * from BaseInfo
--insert Relation(QQID, RelationQQID, RelationStatus)
--select 54789625,88662753,0 Union吗
--select 88662753,8855678,1 Union
--select 54789625,8855678,0
--select * from Relation
--查询 88662753 的好友的 qq号码 昵称 年龄
--select QQID,NickName,Age
--from BaseInfo
--查询当前在线的用户
--select QQID, PassWord, LastLogTime, Online, Level
--from dbo.QQUser
--where Online=0
--北京市 18-45岁 在线 用户信息
--select QQUser.QQID, NickName, Sex, Age, Province, City, Address, Phone
--from QQUser,BaseInfo
--where QQUser.QQID=BaseInfo.QQID and Age>=18and age<=45 and Province like '北京_'
--查询 蝴蝶飞飞 信息
--select QQUser.QQID, NickName, Sex, Age, Province, City, Address, Phone
--from QQUser,BaseInfo
--where QQUser.QQID=BaseInfo.QQID and NickName='蝴蝶飞飞'
--查号码54789625 中 每个省份的总人数 由大到小
--select COUNT(*)as 人数
--from BaseInfo,Relation
--where(Relation.QQID=54789625 and Relation.RelationStatus=0 and Relation.RelationQQID=BaseInfo.QQID)
--group by Province
--order by Province desc
--查询至少有150天未登录的信息 qq号 最后时间 等级 昵称 年龄 时间降序
--select BaseInfo.QQID, NickName, Sex, Age, Province, City, Address, Phone
--from BaseInfo,QQUser
--where BaseInfo.QQID=QQUser.QQID and DATEDIFF(DD,LastLogTime,getdate())>150
--查54789625的好友中等级 10级以上 的用户信息
--select BaseInfo.QQID, NickName, Sex, Age, Province, City, Address, Phone,Level
--from BaseInfo,QQUser
--where BaseInfo.QQID=QQUser.QQID and BaseInfo.QQID=54789625 and Level>=1
------查询54789625 中隐身的信息
--select BaseInfo.QQID,NickName,Age
--from BaseInfo,QQUser,Relation
--where BaseInfo.QQID=QQUser.QQID and QQUser.QQID =Relation.QQID and Relation.RelationStatus=0
--and BaseInfo.QQID=54789625 and Online=2
--好友超过20个 的qq号码 以及好友总数
--select Relation.QQID
--from Relation,BaseInfo,QQUser
--where BaseInfo.QQID=QQUser.QQID and QQUser.QQID =Relation.QQID
--group by Relation.QQID
--having COUNT(Relation.QQID)>=1
--查询黑名单前二十名
--select top 20(RelationQQID),count(RelationQQID)
--from Relation
--group by RelationQQID
--修改数据
--修改隐身登录
--update QQUser set Online=2
--where QQID=8855678
--修改名字 地址
--update BaseInfo
--set NickName='被渴死的鱼',
--Address='解放中路6号院106室'
--where QQID=8855678
--添加黑名单
--update Relation
--set RelationStatus=1
--where QQID=8855678
--提升等级
--update QQUser
--set Level=Level+1
--where Level<=6
--超过365天没登录 锁定QQ 等级-1
--update QQUser
--set Level=-1
--where DATEDIFF(DD,LastLogTime,getdate())>365
--超过20的 提升一个级别
--update QQUser set Level=Level+1
--where QQID in(select QQID from Relation
-- group by QQID having COUNT(Relation.QQID)>=1 )
--拉黑
------update Relation set RelationStatus=1
------where Relation.QQID in (select Relation.QQID from BaseInfo,Relation
------where BaseInfo.QQID=Relation.QQID
------and BaseInfo.QQID=54789625
------and NickName='嘟嘟鱼'
------and RelationStatus=0)
--删除
--54789625的黑名单中的删除
--delete from dbo.Relation
--where QQID=54789625
--1000天未登录删除
--delete from Relation
-- where QQID IN(SELECT QQID FROM QQUser
-- WHERE DATEDIFF(DD,LastLogTime,GETDATE())>1000) OR
-- RelationQQID IN(SELECT QQID FROM QQUser
-- WHERE DATEDIFF(DD,LastLogTime,GETDATE())>1000)
-- delete FROM BaseInfo
-- WHERE QQID IN(SELECT QQID FROM QQUser
-- WHERE DATEDIFF(DD,LastLogTime,GETDATE())>1000)
-- delete FROM QQUser
-- WHERE QQID IN(SELECT QQID FROM QQUser
-- WHERE DATEDIFF(DD,LastLogTime,GETDATE())>1000)
QQ登录 数据库管理
最新推荐文章于 2024-04-21 09:53:33 发布