I was just trying to copy the values of one column into an empty column of another table .
The two tables are students
and payments
.
Students have two columns :
rno - primary key of number type
// i filled it with some entries
amount
//this is completely empty
payments also have same no of columns :
rno - foreign key referencing rno of students table
amount
//this is FILLED
Now to copy amounts
column from payments to students , i tried this command
insert into students(amount) select amount from payments ;
now normally this command works like a charm ,but here it is behaving slightly different . It throws an error that
NULL values cannot be inserted into students.rno
I tried reasoning that maybe its due to different number of entries inserted in two tables , but on eqalizing the no . of entries in both the tables , just the same result .
So the question is that how can i copy in such a situation ?