Hi,
I am new to postgresql. I have a small problem. I have two tables 1)
students and 2) classes with the following structure -
Students -
1) roll_no
2) name
3) class
and Classes -
1) roll_no
2) class
with roll_no being primary key in both the tables. Now I want to
insert the data from the class field in 'classes' into the class field
of 'students'. I tried the following
_______________________________________________________________
INSERT INTO students (class)
SELECT class FROM classes WHERE students.roll_no = classes.roll_no;
_______________________________________________________________
I get the following error -
_______________________________________________________________
ERROR: invalid reference to FROM-clause entry for table "students"
LINE 3: WHERE students.roll_no = classes.roll_no
^
HINT: There is an entry for table "students", but it cannot be
referenced from this part of the query.
_______________________________________________________________
Any suggestions?
Thanking you,
Aditya Pratap V.