首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

高手快来,求一条sql.解决办法

2012-04-18 
高手快来,求一条sql.如果有一表ATablename:AColumn:userID,countryCode,SMS其中userID和countryCode为联合

高手快来,求一条sql.
如果有一表A
Table   name:A
Column   :userID,countryCode,SMS

其中userID和countryCode为联合主键.现在这个表中有这样的数据:

userID         countryCode         SMS
aa@a.com     HK                           259991
aa@a.com     MY                           445588
ss@ww.com   MY                           445588
............

我想用一条sql语句search出来
userID=aa@a.com   and   countryCode=MY这条记录之后的所有记录出来

应该怎样写?

注:database为sql2000


[解决办法]
select id=identity(int,1,1),* into # from A
select userID,countryCode,SMS from # where id> (select max(id) from # where userID= 'aa@a.com ' and countryCode= 'MY ')
[解决办法]
select id=identity(int,1,1),* into tmp from exec(select sqlStatement from OtherTable)
但是这样的语法在sql2000中不允许.改怎么办?
--------------
--试试
exec( 'select id=identity(int,1,1),sqlStatement into tmp from OtherTable ')

热点排行
Bad Request.