日期:2014-05-18  浏览次数:20358 次

高手快来,求一条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 ')