PDA

View Full Version : the LAST()function SQL



alex57
Aug 13th, 2007, 02:36 PM
Could someone please shed some light on this fnction as I need to get the last entered record from a table.

Most websites just say:


SELECT LAST(column) AS [expression] FROM table

what is expression? Why doesnt it work just like other functions such as:


SELECT SUM() FROM table

Thanks

Daemonspyre
Aug 13th, 2007, 03:07 PM
[expression] in this case is an Alias. As in your example, if your tried to retrieve LAST(column), you would have to reference it as $row['LAST(column)'] or as its array position.

When you make it an Alias, you can just reference the alias, as in $row['LastUpdate'].

guelphdad
Aug 13th, 2007, 04:02 PM
you are probably thinking of LAST_INSERT_ID as LAST doesn't exist as a function.

Daemonspyre
Aug 13th, 2007, 05:08 PM
It does exist, but only in Access and MSSQL. It does not exist in MySQL.

guelphdad
Aug 13th, 2007, 05:15 PM
It does exist, but only in Access and MSSQL. It does not exist in MySQL.
thanks for clarifying that. in that case this isn't a mysql thread and will be moved to the general database area.