Advanced MySql Query: Update table with info from another table Advanced MySql Query: Update table with info from another table mysql mysql

Advanced MySql Query: Update table with info from another table


UPDATE business b, people p   SET b.email = p.email WHERE b.business_id = p.business_id   AND p.sort_order = '1'   AND b.email = ''


Note, if sort_order is an INT, then don't use '1' - use 1:

UPDATE business bJOIN People pON p.business_id = b.business_idAND p.sort_order = '1'SET b.email = p.emailWHERE b.email = '';


Try this, it works fine for me.

Update table a, table bSet a.importantField = b.importantField,a.importantField2 = b.importantField2where a.matchedfield = b.matchedfield;