mysql多表更新应该如何是实现呢?对于很多刚接触MySQL数据库的新人来说,都会有这样的疑问,下面就为您介绍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数据库客户端图形界面管理工具推荐MySQL常用维护管理工具Linux VPS/服务器上轻松导入、导出MySQL数据MySQL复制的概述、安装、故障、技巧、工具
人气排行 MySQL数据库启动失败1067进程意外终止的解决办法总结Mysql 1045错误解决办法10款MySQL数据库客户端图形界面管理工具推荐MySQL服务器进程CPU占用100%解决办法MySQL导出导入命令的用例MySQL无法启动、无法停止各种解决方法总结三种常用的MySQL建表语句Mysql清空表的实现方法
查看所有0条评论>>