--QQUser
INSERT INTO QQUser(QQID,PassWord,LastLogTime,Online,[Level])
VALUES('54789625','add512#&','2013-02-16 17:01:35',2,1)
INSERT INTO QQUser(QQID,PassWord,LastLogTime,Online,[Level])
VALUES('88662753','admin0219','2013-02-19 21:08:50',0,5)
INSERT INTO QQUser(QQID,PassWord,LastLogTime,Online,[Level])
VALUES('8855678','guests0221','2013-02-21 16:28:20',1,6)
--BaseInfo
INSERT INTO BaseInfo(QQID,NickName,Sex,Age,Province,City,Address,Phone)
VALUES('54789625','蝴蝶飞飞',1,16,'北京市','北京','亚运村','37547388157668')
INSERT INTO BaseInfo(QQID,NickName,Sex,Age,Province,City,Address,Phone)
VALUES('88662753','秋芙蓉',0,20,'河南省','南阳','方城博望','88715783657725')
INSERT INTO BaseInfo(QQID,NickName,Sex,Age,Province,City,Address,Phone)
VALUES('8855678','双眼皮の潴',1,38,'北京市','北京','双榆村东里','65794968876143')
--Relation
INSERT INTO Relation(QQID,RelationQQID,RelationStatus)
VALUES('54789625','88662753',0)
INSERT INTO Relation(QQID,RelationQQID,RelationStatus)
VALUES('88662753','8855678',1)
INSERT INTO Relation(QQID,RelationQQID,RelationStatus)
VALUES('54789625','8855678',0)
--用例6
SELECT c.RelationQQID,NickName,Age FROM BaseInfo a, dbo.Relation c
WHERE c.QQID='88662753' AND c.RelationSTatus=1 and a.QQID=c.RelationQQID
SELECT QQID,PassWord,LastLogTime,Online,[Level] FROM QQUser
WHERE Online=0
SELECT a.QQID,NickName,Sex,Age,Province,City,Address,Phone FROM BaseInfo a,QQUser b
WHERE Province='北京市' and Online=0 and (Age>=18 and Age<=45)
SELECT QQID,NickName,Sex,Age,Province,City,Address,Phone FROM BaseInfo
WHERE NickName='双眼皮の潴'
SELECT Province,COUNT(Province) FROM Relation b,BaseInfo c
WHERE (b.QQID='54789625' and b.RelationStatus=0 and b.RelationQQID= c.QQID)
GROUP BY Province ORDER BY COUNT(Province) DESC
SELECT QQID,LastLogTime,Online,[Level] FROM QQUser
WHERE DATEDIFF(DD,LastLogTime,GETDATE())>150 ORDER BY DATEDIFF(DD,LastLogTime,GETDATE()) DESC
SELECT RelationQQID,NickName,Age,[Level] FROM Relation C
INNER JOIN BaseInfo as b ON C.QQID='54789625' and C.RelationStatus=0 and c.RelationQQID=b.QQID
INNER JOIN QQUser as E ON C.RelationQQID=E.QQID AND E.Level>=2
SELECT RelationQQID,NickName,Age FROM Relation C
INNER JOIN BaseInfo AS B ON C.QQID='54789625' AND C.RelationStatus=B.QQID
INNER JOIN QQUser AS Q ON C.RelationQQID=Q.QQID AND Q.Online=1
SELECT QQID AS QQ,COUNT(*) AS 好友总数 from Relation
where RelationStatus=0 group by QQID having COUNT(*)>2
SELECT TOP 20 (RelationQQID)as qq,COUNT(*) AS 被当黑名单的人物数
FROM Relation
WHERE RelationStatus=1
GROUP BY RelationQQID ORDER BY COUNT(*) DESC
--用例7
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' and RelationQQID='248624066'
UPDATE QQUser SET Online+=1
WHERE Online<6
UPDATE QQUser SET Online-=1
WHERE DATEDIFF(DD,LastLogTime,GETDATE())>365
UPDATE QQUser SET Online+=1
WHERE QQID IN (SELECT QQID FROM Relation WHERE RelationStatus=0 GROUP BY QQID HAVING COUNT(*)>=2)
UPDATE Relation SET Relationstatus=1
WHERE QQID='286314' and RelationQQID IN (SELECT QQID FROM BaseInfo WHERE NickName='嘟嘟鱼')
and RelationStatus=0
--用例8
DELETE FROM Relation WHERE QQID='54789625' AND Relationstatus=1
DELETE FROM QQUser WHERE QQID='622009019'
DELETE FROM BaseInfo WHERE QQID='622009019'
DELETE FROM Relation WHERE QQID='622009019'
--DELETE FROM QQUser WHERE DATEDIFF(DD,LastLogTime,GETDATE())>1000