I
I
itwebmaster922021-03-23 16:07:45
PHP
itwebmaster92, 2021-03-23 16:07:45

Why can't create table tablename (errno: 150 "Fore ign key constraint is incorrectly formed)" error when creating a foreign key?

Hello... I'm trying to add foreign keys to a table, and for some reason the error is:
Can't create table tablename (errno: 150 "Fore ign key constraint is incorrectly formed)

The key creation query itself looks like this
ALTER TABLE data_nav_toogle_one_way ADD CONSTRAINT fk_markup_ow FOREIGN KEY (`data_nav_ow_id`) REFERENCES `data_nav_toogle_one_way` (id) ON DELETE CASCADE ON UPDATE CASCADE

what could be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2021-03-23
@itwebmaster92

Compare the column types `data_nav_ow_id` and `id`. They must match.
Check the values ​​in the columns. The `data_nav_ow_id` column must not contain values ​​that are not in `id`.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question