1
I’m wanting to use Foreign key but I’m not getting it. This instruction SQL will create a table called tbl_estado
with 4 columns id, nome, uf, pais
and in the column pais
will enter the key Foreign that will be searched in tbl_pais
the id
of the country which is the column id
.
$where = axitech20
(bank)
$tablep = tbl_pais
$tableet = tbl_estado
$sql8 = "CREATE TABLE IF NOT EXISTS $aonde.$tablee (
id INT(6) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY,
nome VARCHAR(75) DEFAULT NULL,
uf VARCHAR(5) DEFAULT NULL,
pais INT(6) DEFAULT NULL KEY '??????????' ($tablep)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=28";
I’m not getting to do the relationship that’s something in there ?????????? of the instruction. Can help me to hit the foreign key
?
Have you tried to check on mysql documentation ?
– gmsantos
I tried yes that’s how I managed to create the instruction but I’m not getting the instructions that go there
???????
– Marcos Vinicius
FOREIGN KEY (product_category, product_id) REFERENCES product(category, id)
– gmsantos