0

I have the following query that works...

SELECT u.route_id, g.route_id
FROM user_route u
JOIN user_address a ON a.address_id = u.route_begin_id
JOIN user_address b ON b.address_id = u.route_finish_id
JOIN google_route g ON g.route_begin_id = a.address_google_id 
AND g.route_finish_id = b.address_google_id

But I would like to update u.google_route_id with g.route_id's value

Can anyone suggest how I go about this, thanks.

Stephen Brown
  • 502
  • 1
  • 9
  • 22
  • 1
    possible duplicate of [mysql update join](http://stackoverflow.com/questions/15209414/mysql-update-join) – sgeddes Dec 10 '14 at 20:07

1 Answers1

0
update user_route u
JOIN user_address a ON a.address_id = u.route_begin_id
JOIN user_address b ON b.address_id = u.route_finish_id
JOIN google_route g ON g.route_begin_id = a.address_google_id 
AND g.route_finish_id = b.address_google_id)
set u.google_route_id=g.route_id
Gordon Linoff
  • 1,198,228
  • 53
  • 572
  • 709
jdog
  • 2,431
  • 5
  • 37
  • 70