I want to UPDATE
table row in member_network
table using WHERE
clause by team_id = 91
and using JOIN
.
Main table member_network
structure look like:
| id | network_profile_name |
|----------------------------|
| 1 | John Doe |
I have two fields in two more connected tables with the values I need.
Table team_member_network
structure looks like:
| id | team_member_id | member_network_id |
|----|----------------|-------------------|
| 2 | 1 | 1 |
Table team_member
:
| id | team_id | member_id |
| ------|---------|-----------|
| 1 | 91 | 1679817 |
This is some kind of reverse relationship
My work so far:
UPDATE member_network
SET
network_profile_name = 'James Bond'
JOIN team_member_network
ON member_network.id = team_member_network.member_network_id
JOIN team_member
ON team_member_network.team_member_id = team_member.id
WHERE team_id = 91;
With an error:
Syntax error: 7 ERROR: syntax error at or near "JOIN
Works on SELECT
but how should I use JOIN
when updating selected row? Related posts I found did not help in my case..
3
Answers
Just remove the comma (,) in the end of the line
then try it should work
It is:
In your case:
I don’t see why you would need JOIN for this:
If you really want to "join" the tables, then you need to do that in the WHERE clause of the UPDATE statement. As documented in the manual you need a FROM clause first – but that should not repeat the target table.