Answer the question
In order to leave comments, you need to log in
How to pick up identical fields in a one-to-many relationship in postgres?
Good afternoon,
There are 2 tables - m_hotels (hotels), mc_rooms (hotel rooms)
The connection is as follows: mc_rooms.hotel_id == m_hotels.id
I need to assign m_hotels.firm_id values to the c_rooms.firm_id fields.
I tried this:
update mc_rooms set mc_rooms.firm_id = m_hotels.firm_id where mc_rooms.hotel_id = m_hotels.id;
Answer the question
In order to leave comments, you need to log in
UPDATE mc_rooms
SET firm_id=m_hotels.firm_id
from m_hotels
WHERE mc_rooms.hotel_id=m_hotels.id;
UPDATE t
SET col1 = value
FROM table1 as t
--Далее JOIN если надо и т.д.
WHERE и т.д.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question