This is going to sound strange but I have a webpage that displays a form showing the last record added. This is because further records share a lot of the same data, so only a few fields have to be changed. I use the max(ID) to do this:
Expand|Select|Wrap|Line Numbers
- <cfquery name="lastid" datasource="swwdrawings">
- select *
- from tblDrawingsData
- where ID = (select max(ID) from tblDrawingsData where AddedBy = '#username#')
- </cfquery>
Expand|Select|Wrap|Line Numbers
- <cfquery name="lastfive" datasource="swwdrawings" maxrows="5">
- select *
- from tblDrawingsData
- where AddedBy = '#username#'
- order by ID desc
- </cfquery>
Expand|Select|Wrap|Line Numbers
- <cfquery name="lastfive" datasource="swwdrawings" maxrows="5">
- select *
- from tblDrawingsData
- where AddedBy = '#username#' and ID <> (select max(ID) from tblDrawingsData where AddedBy = '#username#')
- order by ID desc
- </cfquery>
Neil