Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/01/2009, 22:42
Chuecko
 
Fecha de Ingreso: junio-2008
Mensajes: 119
Antigüedad: 15 años, 10 meses
Puntos: 1
Saber el ultimo autoincrement relacionado

Hola gente tengo la siguiente estructura

Código PHP:
      CREATE TABLE  `notas` (
        `
notasIDint(10UNSIGNED NOT NULL AUTO_INCREMENT,
        `
userIDint(10UNSIGNED NOT NULL,
        `
posterTimeint(10UNSIGNED NOT NULL,
        `
posterIPtinytext NOT NULL,
        `
titulotinytext NOT NULL,
        `
cuerpotext NOT NULL,
        `
tagsvarchar(16) DEFAULT NULL,
        `
categoriavarchar(16NOT NULL,
        `
visitasIDmediumint(8unsigned NOT NULL auto_increment,
        `
visitasIPtinytext NOT NULL,
        
PRIMARY KEY  (`notasID`),
        
KEY `FK_notas_1` (`userID`),
        
FOREIGN KEY (`userID`) REFERENCES `usuarios` (`userID`)
      ) 
ENGINE=InnoDB DEFAULT CHARSET=latin1
y realizo esta insercion

Código PHP:
$sql="INSERT INTO notas (notasID ,userID,posterTime,posterIP,titulo,cuerpo,tags,categoria)VALUES (NULL , '$userID', '$time', '$ip', '$titulo', '$cuerpo', '$tags', '$categoria')"
La pregunta es saber cual es el valor de notasID, asi q despues del momento de crearla la pueda enlazar....

Muchas gracias espero que me entiendan...