[英]how to update a table and insert a new record to another table in one query?
[英]select one record each from two table. update the one value by matching the another one to a new table
我有三個表,例如table1,table2,table3。
我需要一個mysql解決方案。
從table1,table2中選擇table1.val1,table2.val1並更新返回的值。
更新表3 的設定值= table1.val1其中value = table2.val1
我的查詢不起作用..
update db1.proprietor_profile_tbl as c3 set c3.PPROFILE_profileid=(select c2.COM_id from db2.company_profile_tbl as c1,db1.company_profile_tbl as c2 where c1.COM_name=c2.COM_name and COM_profiletype!=4) where c3.PPROFILE_profileid=c1.COM_id
“ where子句”中的未知列“ c1.COM_id”
UPDATE table3 t3
INNER JOIN table2 t2
ON t3.pcomid = t2.comid
INNER JOIN table1 t1
ON t1.name=t2.name
SET t3.pcomid = t1.comid
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.