Ver Mensaje Individual
  #3 (permalink)  
Antiguo 05/04/2008, 06:12
jurena
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Cáceres
Mensajes: 3.735
Antigüedad: 16 años, 1 mes
Puntos: 300
Re: Ayuda con Insert

échale un vistazo a la función de MySQL last_insert_id:
http://mysql.conclase.net/curso/index.php?fun=LAST_INSERT_ID"
y en el manual oficial:
http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id

Si trabajas por ej. con PHP o con algún otro programa, también deberías mirar mysql_insert_id, una función de MysQL para la API
http://dev.mysql.com/doc/refman/5.0/en/mysql-insert-id.html

Una opción casera y poco fiable, según dicen los técnicos, es ordenar por el id de modo descendente y hacer un limit 0, 1
SELECT id FROM tabla ORDER BY id DESC LIMIT 0,1.