4
I’m trying to put together tables and add one chave estrangeira
, for example, a shopping list has referência
of id
from the buyers' table.
I did it this way:
alter table compras add foreign key (compradores_id) references compradores(id);
insert into compras (valor, recebido, data, compradores_id) values (1500, 1, '2016-06-02', 15);
*As id's
of the buyers table only go up 3
*Both columns (compradores.id e compras.compradores_id
) were configured as int not null
He accepts the command of insert
good and records, how can I fix that ?
You could post the fields and type of each field of these two tables?
– Ariel Inacio Correa
Your table engine is innodb or mysam?
– rray
You need to have Constraint, you have to be of the same type, integer (11), integer (11), unsignet, not null and so on...
– Diego Souza
@How do I verify that ?
– Murilo Melo
@Gumball, I’ve spelled them both the same :/ so I don’t understand why you’re bugging
– Murilo Melo
In the creation of the table at the end has this information.
– rray
@rray, both are Myisam
– Murilo Melo
Try to put Innodb
– Diego Souza