時間:2015/6/28來源:IT貓撲網(wǎng)作者:網(wǎng)管聯(lián)盟我要評論(0)
mysql多表更新應該如何是實現(xiàn)呢?對于很多剛接觸MySQL數(shù)據(jù)庫的新人來說,都會有這樣的疑問,下面就為您介紹MySQL多表更新的方法,供您參考。
MySQL多表更新:
- update contact c, contactdroit cd
- set c.user_name = '$username', c.nom = '$lastname', c.prenom = '$firstname', c.passcode = '$password', cd.droit_id = '$droitid'
- where c.contact_id = '$id' and c.contact_id = cd.contact_id;
示例:
- mysql> create table one(id int(10), name varchar(20));
- Query OK, 0 rows affected (0.03 sec)
- mysql> create table two(id int(10), name varchar(20));
- Query OK, 0 rows affected (0.05 sec)
- mysql> insert one value(1, '1');
- Query OK, 1 row affected (0.00 sec)
- mysql> insert two value(22, '22');
- Query OK, 1 row affected (1.02 sec)
- mysql> update one o, two t set o.name='oo', t.name='tt';
- Query OK, 2 rows affected (0.00 sec)
- Rows matched: 2 Changed: 2 Warnings: 0
- mysql> select * from one;
- +------+------+
- | id | name |
- +------+------+
- | 1 | oo |
- +------+------+
- 1 row in set (0.00 sec)
- mysql> select * from two;
- +------+------+
- | id | name |
- +------+------+
- | 22 | tt |
- +------+------+
- 1 row in set (0.00 sec)
關鍵詞標簽:MySQL
相關閱讀
熱門文章 10款MySQL數(shù)據(jù)庫客戶端圖形界面管理工具推薦MySQL常用維護管理工具Linux VPS/服務器上輕松導入、導出MySQL數(shù)據(jù)MySQL復制的概述、安裝、故障、技巧、工具
人氣排行 MySQL數(shù)據(jù)庫啟動失敗1067進程意外終止的解決辦法總結Mysql 1045錯誤解決辦法10款MySQL數(shù)據(jù)庫客戶端圖形界面管理工具推薦MySQL服務器進程CPU占用100%解決辦法MySQL導出導入命令的用例MySQL無法啟動、無法停止各種解決方法總結三種常用的MySQL建表語句Mysql清空表的實現(xiàn)方法