Update statement

Hi, I have this table created.

CREATE TABLE `prueba` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `fecha` datetime NOT NULL,
  `usuario` varchar(45) DEFAULT NULL,
  `notas` varchar(245) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

I’m trying to update the “notas” column when my id equals to the last row. This code updates all my rows, not just the last one, the “SELECT MAX()” it’s not working.

notas = event.source.parent.getComponent('detalle falla').text
update = system.db.runPrepUpdate("UPDATE prueba SET notas = ? WHERE id = (SELECT MAX(id))",[notas])

Try this:

notas = event.source.parent.getComponent('detalle falla').text
update = system.db.runPrepUpdate("UPDATE prueba SET notas = ? WHERE id = (SELECT MAX(id) FROM prueba)",[notas])

I tried that before, this is the error "You can’t specify target table ‘prueba’ for update in FROM clause
"

Okay, right, try this:

notas = event.source.parent.getComponent('detalle falla').text
update = system.db.runPrepUpdate("UPDATE prueba SET notas = ? ORDER BY id DESC LIMIT 1",[notas])

thank you nmudge, it worked, you are very helpful!, thanks again.