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

Hola gente tengo la siguiente estructura

Código PHP:
      CREATE TABLE  `notas` (
        `
notasID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
        `
userID` int(10) UNSIGNED NOT NULL,
        `
posterTime` int(10) UNSIGNED NOT NULL,
        `
posterIP` tinytext NOT NULL,
        `
titulo` tinytext NOT NULL,
        `
cuerpo` text NOT NULL,
        `
tags` varchar(16) DEFAULT NULL,
        `
categoria` varchar(16) NOT NULL,
        `
visitasID` mediumint(8) unsigned NOT NULL auto_increment,
        `
visitasIP` tinytext 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...