mysql - how can I update a table but needing to get the update value from another select of the same table and other one? -


i have problem:

i have tablea , tableb

tableb needs tablea's id in field.

tableb , tablea have common field 'email'

ive tried this

update tableb set tableb.reference = (select a.id tablea a, tableb b a.email = b.email) 

unfortunately when run query says cant specify target 'tableb' updates in clause.

any idea how solve or run query this?

update tablea, tableb set tableb.id = tablea.id tablea.email = tableb.email 

or one:

update tableb inner join tablea using (email) set tableb.id = tablea.id 

your query possible, need fix it:

update tableb set tableb.id = (select a.id tablea a, tableb b a.email = b.email) 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -