I have moved from mysql to psql, but find it hard to get my head around the UPDATE statement using multiple left joins.
How would you rewrite this in Postgres? (I am using postresql 9.4)
update task t
left join project p on t.project_id = p.id
left join client c on t.client_id = c.id
left join user u on t.user_id = u.id
set t.project_name = p.name,
t.client_name = c.name,
t.user_name = u.name;
Any pointer will be welcome.
project? With inner join toprojectit's something like thisUPDATE task SET project_name = p.NAME ,client_name = c.NAME ,user_name = u.NAME FROM project p ON task.project_id = p.id LEFT JOIN client c ON task.client_id = c.id LEFT JOIN user u ON task.user_id = u.id;. To use aLEFT JOINwithprojectdo a self-join to task or use subqueries in theSETpart...