Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPDATING the last field in a table?

Status
Not open for further replies.

maverik59

Programmer
Oct 30, 2002
67
GB
Easyone for u SQL guys, how do i update the last record in a table?
I have this but it doesn't work
UPDATE usertrack SET heading_to = "123" WHERE unique_id=max(unique_id)
 
Should be something like:

UPDATE usertrack SET heading_to = "123" WHERE unique_id=
(select max(unique_id) from usertrack)
 
OOPS - should be single NOT double quotes to delimit the string: '123'
 
It still doesn't work??
Error Executing Database Query.
Syntax error or access violation: You have an error in your SQL syntax near ' UPDATE usertrack SET heading_to = '/images/orgcharts/busimprovement.jpg' WHERE unique_id= (select max(unique_id) from usertrack)
DATASOURCE luthor
VENDORERRORCODE 1064
SQLSTATE 42000

 
"Syntax error" - looks OK to me, but . . . . .

"or access violation" - do you have update rights on the table?
 
I have worked out that my database (mascon) or server (coldfusion) does not support subqueries. Perhaps I can split the SQL and store them in variables.
Many Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top