0
You’re making a mistake Can't create table
when creating this table in Mysql. I have no idea where problem D is:
CREATE TABLE IF NOT EXISTS `tbnoticiasrel` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`id_noticia` bigint(20) NOT NULL,
`id_noticia_relacionada` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY fk_id_noticia(`id_noticia`)
REFERENCES tbnews(`id`),
FOREIGN KEY fk_id_noticia_relacionada(`id_noticia_relacionada`) ,
REFERENCES tbnews(`id`)
)
you already have the fk_id_noticia_related table created?
– MoisesGama
Try
FOREIGN KEY (\
id_noticia`) REFERENCES ...` without the FK name.– KaduAmaral
fk_id_news_related is the name I’m giving to my FK -
– Estácio Di Fabio
Which error message the bank shows you?
– Ulysses Alves
gave the same error this way Kaduamaral
– Estácio Di Fabio
shows Cant 'create table'nameserver'. 'nameserver' (Errno: 150)
– Estácio Di Fabio
puts
SET FOREIGN_KEY_CHECKS=0;
on the line before theCREATE TABLE IF NOT EXISTS tbnoticiasrel
with that he will not check theFOREIGN KEY
– MoisesGama
with this SET FOREIGN_KEY_CHECKS=0; worked, thanks (:
– Estácio Di Fabio
@Estaciodifabio tried to execute the code without the
virgula
that I mentioned? That oneSET FOREING_KEY...
seems to be a Alternative Solution.– KaduAmaral