Skip to content Skip to sidebar Skip to footer

Mysql: Update Value From Query

I've got a query: SELECT a.id, b.products_id,a.zenid FROM titles a, ANOTHERDATABASE.products_description b WHERE b.products_name = a.title It gives id products_id zenid 57

Solution 1:

This is how you are updating a table using a join in MySQL:

UPDATE titles a
  INNER JOIN ANOTHERDATABASE.products_description b
    ON b.products_name = a.title
SET a.zenid = b.products_id

Solution 2:

update a
set a.zenid=b.products_id
from titles a inner join ANOTHERDATABASE.products_description b 
on b.products_name = a.title  

Post a Comment for "Mysql: Update Value From Query"