On 2 Mar 2010, at 11:31am, Matt Eeles wrote: > I'm trying to update a field of the last record using UPDATE and MAX(). > The following query parses ok but updates all records. Any reason why ? > > > > UPDATE logs SET Stop = DATETIME('NOW') WHERE (SELECT MAX(ID) FROM logs)
Your WHERE clause tells it to. SQLite is updating all records where the WHERE clause evaluates to TRUE. What you want might be more like ... WHERE (SELECT MAX(ID) FROM logs) = ID I'm at work and can't test it right now. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users