I have the following tables Projects and ProjectFields. I am trying to populate one with values from another plus some other values, this way:
INSERT INTO "ProjectFields" ("projectId", name, type, "isDefault")
(SELECT "projectId", 'Notes', 'textarea', true FROM "Projects"), -- creates one field called 'Notes' for every project.
(SELECT "projectId", 'Bio', 'textarea', true FROM "Projects"), -- creates one field called 'Bio' for every project.
(SELECT "projectId", 'Photo', 'text', true FROM "Projects"); -- creates one field called 'Photo' for every project.
The idea is that every project must have three referenced fields in the ProjectFields table. I know that the code above doesn't work, is there any way to do this using PostgreSQL ?
If you have a better idea please tell me, thank you.