I have 4 tables:
**appdetail**
id, alocation
**alocation**
id, appdetail
**place**
id, name
**location_place**
alocation, place
location_place.alocation points to alocation.id location_place.place points to place.id
I want to copy the values of location_place.alocation to appdetail.alocation. I tried the solution from https://stackoverflow.com/a/8963158/815859. However, I am getting "SQL command not properly ended" error. My query is
update appdetail set
alocation =i.alocation
from
(select lp.alocation
from location_place lp,
alocation apl,
appdetail ad
where
lp.alocation = apl.id
and
apl.id in (547,294)
and
ad.id = apl.appdetail
)i
where appdetail.alocation = i.alocation
The DBFiddle is at https://www.db-fiddle.com/f/8SB3tHxWVY7NbCyzpKLhRG/4