AER
AER

Reputation: 1531

PSQL not updating uniquely but copying value onto all entries---Foreign Key update

This is looking for solutions in PSQL or PGAdmin III:

I have set up the SQL command as follows as per this question:

UPDATE members
SET pers_id=P.pers_id
--SELECT *
FROM persons P
INNER JOIN members M
ON M.full_name=P.full_name

However it is not updating the column pers_id with the individual value instead it is copying the data point from the first query onto all entries.

It should be noted that pers_id is a foreign key in the members table.

Upvotes: 0

Views: 22

Answers (1)

Khalid Amin
Khalid Amin

Reputation: 902

Try this:

UPDATE members
SET pers_id=persons.pers_id
FROM persons
WHERE members.full_name = persons.full_name

Upvotes: 1

Related Questions