Click here to Skip to main content
15,901,368 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
select top 6 * from Table1 where T_id = "1" order by id desc

I get the result but please specify other way to get result

Please Tell me new query with get record with Timestamp


TimeStamp => Column for store datetime in Table1
In Table1 multiple record are there.
T_id is reference key for other table like Table2.
id is primary key for Table1.
Posted
Updated 12-Sep-13 1:30am
v4
Comments
Thanks7872 12-Sep-13 5:55am    
Whats the problem with this one?
Patel Mayank MCA 2-Oct-13 3:00am    
I do this query using time based that's a problem

The query you provided does not entirely ensure you will get the last 6 added!
It is dependent on sorting defaults (or specified ones) and the nature of the T_ID coloumn (which is configurable in most cases).

What you should do is store the creation time in a DateCreated coloumn. And return the TOP 6 out of the query sorting by the DateCreated.

Cheers,
Edo
 
Share this answer
 
v2
SQL
select top 1 * from Product
where ManufacturingDate = (select MAX(Manufacturingdate) from Product)
 
Share this answer
 
Comments
Patel Mayank MCA 13-Sep-13 2:23am    
Thnks For y'r suggestion

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900