0

I have the following query

select * from Properties 
join PPHL on PPHL.postcode = Properties.postcode
and PPHL.name = Properties.propertyname
and PPHL.id <> Properties.propertycode
where Properties.clientid = 1

I want to update all the Properties from the results of this query with the id from the PPHL table, does anyone know the correct sql I need to do this? I am running this on mysql 5.

1 Answer 1

2

The set clause goes after the table joins. See the MySQL documentation for UPDATE for syntax help.

UPDATE Properties 
    JOIN PPHL ON PPHL.postcode = Properties.postcode
             and PPHL.name = Properties.propertyname
             and PPHL.id <> Properties.propertycode

SET Properties.propertycode = PPNL.id
WHERE Properties.clientid = 1
Sign up to request clarification or add additional context in comments.

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.