I am working on a django based project which created two tables `table1` and `table2` with a foreign key from `table2` to `table1`. I need to insert some values manually into `table2`. On trying to do so in MySQL I get the constraint failure error. I checked thoroughly, corresponding entries required for a foreign key constraint already exist in `table1`. I looked into some previous questions on SO but could not find an appropriate solution.

Table1 Schema:

```
+------------+---------------+------+-----+---------+----------------+
| Field      | Type          | Null | Key | Default | Extra          |
+------------+---------------+------+-----+---------+----------------+
| id         | int(11)       | NO   | PRI | NULL    | auto_increment |
| email      | varchar(100)  | NO   |     | NULL    |                |

```

Table 2:

```
+-------------+---------------+------+-----+---------+----------------+
| Field       | Type          | Null | Key | Default | Extra          |
+-------------+---------------+------+-----+---------+----------------+
| id          | int(11)       | NO   | PRI | NULL    | auto_increment |
| km          | varchar(1000) | YES  |     | NULL    |                |
| owner_id    | int(11)       | NO   | MUL | NULL    |                |
| receiver_id | int(11)       | NO   | MUL | NULL    |                |
+-------------+---------------+------+-----+---------+----------------+

```

The insert statement `insert into crest_recipient values(id,owner_id=5,receiver_id=5,km="hello world");` or similar ones fail with the exact error as

> 
> Cannot add or update a child row: a foreign key constraint fails
>  (crest.crest\_recipient CONSTRAINT
>  crest\_recipient\_owner\_id\_4943116a1387be04\_fk\_crest\_user\_id FOREIGN
>  KEY (owner\_id) REFERENCES crest\_user (id))
> 
> 
>