0

I have three tables

X [id,event_time]
Y [x_id,z_id] -- here x_id is id from X and z_id is id from Z
Z [id,event_time]

Now I want to update the values of X[event_time] with Z[event_time]. Is there any query that can be formed for doing this?

3 Answers 3

1
update x
set x.event_time = t.event_time
from (
    select z.event_time
        ,y.x_id
    from z
    join y on z.id = y.z_id
    ) t
where x.id = t.x_id
Sign up to request clarification or add additional context in comments.

Comments

1

something like this

UPDATE X
SET event_time = z.event_time
FROM Z z
JOIN Y y ON y.z_id = z.id
JOIN X x ON y.x_id = x.id

Comments

1
UPDATE X
SET event_id = (SELECT z.event_id FROM Z INNER JOIN Y WHERE Z.id=Y.z_id and Y.x_id=X.id)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.