I'm quite new to this and I need some help.
I would like to copy rows of data from one table to another table in the same database using pgadmin. However, they have slightly different column id. Is there a way to write a script to match them and do a copy?
Please help. Thank you.
I have tried the following( to copy existing data in STUD table into STUDENT table):
CREATE TABLE STUDENT(
Student_id INT,
Student_name TEXT,
Student_address TEXT
);
INSERT INTO STUDENT
SELECT * FROM STUD AS D
WHERE(
Student_id = D.id,
Student_name = D.name
);
I have 2 tables STUDENT and STUD. Under STUDENT table, I have Student_id, Student_name and Student_address. Under STUD table, I have name and id. The rows in the both the tables are not in order.
** ADD ON**
The table in STUD does not come with the Student_address column. Only the STUDENT table has. Since STUD does not have Student_address, I would like to put Student_address in STUDENT table as NULL. Is it possible to write a general script where columns in STUDENT table that does not exist in Stud will be NULL?
EDIT** Instead of NULL, I am required to insert "TBC"
wherestatement supposed to do? You can't "join" between the target table and the source table. Are you maybe trying to update existing rows instead?