Ask a Question related to Coldfusion Database Access, Design and Development.
-
midimidi #1
Get all and the last ID of database
Newbie here. I know very little about queries. How can I find the last ID of
a recordset? The only solution I found was the following, and while it works,
I can't seem to figure out how to have both it and a 'get all' in the same
query. SO - in the end, I currently have the following TWO queries, and I'm
assuming there's a better way to do this since they're both coming from the
same database. I need the last ID for an indexed cfloop. The database is
currently MS Access. <cfquery name='all' datasource='month'> SELECT * FROM
month </cfquery> <cfquery name='all_count' datasource='month'> SELECT
Count(*) as LastID FROM month </cfquery>
midimidi Guest
-
MySQL Database not retrieving the full database
Hi, I am using MySQL and PHP for my repository. It has 500+ records. till now it was displayiing all records in the database, but since from one... -
Import Data from flat-database to relational-database
Before I start I need some tips and pleas excuse my bad english. I have two databases, one is flat and one is a relational database. example ... -
NEWBIE HELP Import Data from flat-database to relational-database
I want to import Data from a simple Database, which contains all Information in one big record into a relational Database and split up the big... -
Passing database info to page allow user input then pass into another database
Hi I really am going crazy! I'm using VBScript, ASP, and SQL My page reminds me of a shopping cart but looking at shopping cart examples has not... -
Another user has modified the contents of this table or view; the database row you are modifying no longer exists in the database;
Hi, I am testing a trigger that and I am getting this error message saying "Another user has modified the contents of this table or view; the... -
Bill Sahlas #2
Re: Get all and the last ID of database
to get the last value in any column you'd use the LAST() scalar function -
this is a common function among database verndors. These are some other
methods - LAST(<FIELDNAME>), MAX(<FIELDNAME>), MIN(<FIELDNAME>),
FIRST(<FIELDNAME>), AVG(<FIELDNAME>).
For you're example though it appears that you're using the Count(*) method
to get the number for your to="" part of the cfloop. You can use this
instead to="all.recordcount"
Here are some other attributes at your disposal
Variable name Description
query_name.currentRow
Current row of query that cfoutput is processing.
query_name.columnList
Comma-delimited list of the query columns.
query_name.RecordCount
Number of records (rows) returned from the query.
Also see
[url]http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=p art_cfm.htm[/url]
"midimidi" <webforumsuser@macromedia.com> wrote in message
news:cvd80i$kkr$1@forums.macromedia.com...> Newbie here. I know very little about queries. How can I find the last
> ID of
> a recordset? The only solution I found was the following, and while it
> works,
> I can't seem to figure out how to have both it and a 'get all' in the same
> query. SO - in the end, I currently have the following TWO queries, and
> I'm
> assuming there's a better way to do this since they're both coming from
> the
> same database. I need the last ID for an indexed cfloop. The database is
> currently MS Access. <cfquery name='all' datasource='month'> SELECT *
> FROM
> month </cfquery> <cfquery name='all_count' datasource='month'> SELECT
> Count(*) as LastID FROM month </cfquery>
>
Bill Sahlas Guest
-
Steve-DDOTS #3
Re: Get all and the last ID of database
You can also query
SELECT Max(RecordID) AS ThisMaxRecoredID FROM xxxxxx
That will produce the last recordid as thismaxrecordid
Steve-DDOTS Guest
-
Steve-DDOTS #4
Re: Get all and the last ID of database
Of course, 'RecordID' is your key incrementing ID for the table.
Steve-DDOTS Guest
-
kyle969 #5
Re: Get all and the last ID of database
You can treat the resultSet as an array. To get the last value try this:
lastVal = queryName.columnName[queryName.recordCount];
kyle969 Guest



Reply With Quote

