IT貓撲網(wǎng):您身邊最放心的安全下載站! 最新更新|軟件分類|軟件專題|手機版|論壇轉(zhuǎn)貼|軟件發(fā)布

您當前所在位置:首頁數(shù)據(jù)庫MYSQL → MySQL多表更新示例

MySQL多表更新示例

時間:2015/6/28來源:IT貓撲網(wǎng)作者:網(wǎng)管聯(lián)盟我要評論(0)

mysql多表更新應該如何是實現(xiàn)呢?對于很多剛接觸MySQL數(shù)據(jù)庫的新人來說,都會有這樣的疑問,下面就為您介紹MySQL多表更新的方法,供您參考。

MySQL多表更新:

  1. update contact c, contactdroit cd   
  2. set c.user_name = '$username'c.nom = '$lastname'c.prenom = '$firstname'c.passcode = '$password'cd.droit_id = '$droitid'   
  3. where c.contact_id = '$id' and c.contact_id = cd.contact_id;  

示例:

  1. mysql> create table one(id int(10), name varchar(20));  
  2. Query OK, 0 rows affected (0.03 sec)  
  3.  
  4. mysql> create table two(id int(10), name varchar(20));  
  5. Query OK, 0 rows affected (0.05 sec)  
  6.  
  7. mysql> insert one value(1, '1');  
  8. Query OK, 1 row affected (0.00 sec)  
  9.  
  10. mysql> insert two value(22, '22');  
  11. Query OK, 1 row affected (1.02 sec)  
  12.  
  13. mysql> update one o, two t set o.name='oo't.name='tt';  
  14. Query OK, 2 rows affected (0.00 sec)  
  15. Rows matched: 2 Changed: 2 Warnings: 0  
  16.  
  17. mysql> select * from one;  
  18. +------+------+  
  19. | id   | name |  
  20. +------+------+  
  21. |    1 | oo   |  
  22. +------+------+  
  23. 1 row in set (0.00 sec)  
  24.  
  25. mysql> select * from two;  
  26. +------+------+  
  27. | id   | name |  
  28. +------+------+  
  29. |   22 | tt   |  
  30. +------+------+  
  31. 1 row in set (0.00 sec)  
  32.  

關鍵詞標簽:MySQL

相關閱讀

文章評論
發(fā)表評論

熱門文章 10款MySQL數(shù)據(jù)庫客戶端圖形界面管理工具推薦10款MySQL數(shù)據(jù)庫客戶端圖形界面管理工具推薦MySQL常用維護管理工具MySQL常用維護管理工具Linux VPS/服務器上輕松導入、導出MySQL數(shù)據(jù)Linux VPS/服務器上輕松導入、導出MySQL數(shù)據(jù)MySQL復制的概述、安裝、故障、技巧、工具MySQL復制的概述、安裝、故障、技巧、工具

相關下載

人氣排行 MySQL數(shù)據(jù)庫啟動失敗1067進程意外終止的解決辦法總結Mysql 1045錯誤解決辦法10款MySQL數(shù)據(jù)庫客戶端圖形界面管理工具推薦MySQL服務器進程CPU占用100%解決辦法MySQL導出導入命令的用例MySQL無法啟動、無法停止各種解決方法總結三種常用的MySQL建表語句Mysql清空表的實現(xiàn)方法