有两个表 A,B
A:
DoorID,DpNo
B:
DoorID,EnterType,DateTime怎么样用SQL语句查询着两个表得到最新的记录集:DpNO,EnterType

解决方案 »

  1.   

    select A.Dpno,B.EnterType from A,B where A.DoorID=B.DoorID
      

  2.   

    1.  select A.Dpno,B.EnterType from A,B where A.DoorID=B.DoorID2.  select A.Dpno,B.EnterType from A left join B on A.DoorID=B.DoorID
      

  3.   

    select A.Dpno,B.EnterType from A,B where A.DoorID=B.DoorID order by DateTime desc
    没有这句order by DateTime desc怎么得到最新的记录集?
      

  4.   

    看到最新两个字了吗????要查找datetime最新的那条记录!!!!!!!!!!!!!!搞什么啊?
      

  5.   

    我要返回的记录是B表里datetime为最新的那条记录(DpNO,EnterType),只有一条记录的!!!!!!!!!!!!!!!!!!看清楚再回答
      

  6.   

    select A_.DpNo,B_.EnterType from A as A_ ,(select DoorID,EnterType from B where DateTime = (select max(DateTime) from B)) B_ where A_.DoorID = B_.DoorID
      

  7.   

    select top 1 A.Dpno,B.EnterType from A,B where A.DoorID=B.DoorID order by DateTime desc