When you're using foreign key, your order of columns should be same for insertion.
For example, if you're adding (userid, password)
in table1 from table2 then from table2 order should be same (userid, password)
and not like (password,userid)
where userid
is foreign key in table2 of table1.