2013-12-18 198 views
1

我想最後更新的行此記錄24763獲取最後更新記錄提交

nc_comment_id nc_id nc_user_id nc_comment_added_by nc_comment nc_comment_added_on 
1    24763 2051  Amit sharma   nc created 2013-09-23 17:45:00.000 
2    24763 2051  Amit Sharma   nc updated  2013-09-23 17:45:00.000 
44    24763 2051  Pravin    NULL  2013-10-22 12:13:48.000 

45    24789 2050  Arun     nc_created  2013-10-22 12:13:48.000 

我想用SQL查詢

44    24763 2051  Pravin    NULL  2013-10-22 12:13:48.000 

回答

2

這個紀錄對於MSSQL:

SELECT TOP 1 * FROM tablename 
WHERE nc_id = 24763 
ORDER BY nc_comment_added_on desc 

爲MySQL :

SELECT * FROM tablename 
WHERE nc_id = 24763 
ORDER BY nc_comment_added_on desc 
LIMIT 1 
+0

Hey'BABL86' 謝謝 – AmitykSharma

1

試試下面的查詢

select top 1 * from tbla where nc_id=24763 order by nc_comment_id desc