Hi
I do create two tables :
Table A :
id auto_increment
txt
Table B :
B_id
txt
id
Using the syntax i found in the manual :
CREATE TABLE parent(
id INT NOT NULL,
PRIMARY KEY (id)
) TYPE=INNODB;
CREATE TABLE child (
id INT,
parent_id INT,
INDEX par_ind (parent_id),
FOREIGN KEY (parent_id) REFERENCES parent(id)
ON DELETE SET NULL
) TYPE=INNODB;
So i could not use auto_increment to B_id
because mysql says i can not have two auto fields ????
How can i increment the B_id field using php/mysql functions i think a
mysql function will work is that right?
Below is the sql i execute:
CREATE TABLE tableA(
cod_A INT NOT NULL AUTO_INCREMENT,
txt_assunto VARCHAR ( 255 ) NOT NULL
PRIMARY KEY (cod_A)
) TYPE=INNODB;
CREATE TABLE tableB (
cod_B INT NOT NULL,
link VARCHAR( 255 ) NOT NULL,
txt_desc TEXT,
cod_A INT,
INDEX c_a ( cod_A ),
FOREIGN KEY (cod_A) REFERENCES tableA(cod_A)
ON DELETE SET NULL
) TYPE=INNODB;
I paste the sql to code critique
Thank´s in advance