Home >Database >Mysql Tutorial >mysql从另一张获取数据的方法_MySQL

mysql从另一张获取数据的方法_MySQL

WBOY
WBOYOriginal
2016-06-01 13:47:03906browse

bitsCN.com

 

方法一

CREATE TABLE tmp AS SELECT a.id FROM t_user t JOIN temp a ON t.email = a.email;

方法二

INSERT INTO t_user (id,username,PASSWORD,email,user_type,STATUS) SELECT id,REPLACE(email,'@','_'),PASSWORD,email,'0','0' FROM temp;

这两个sql都是从另外一张中获取的数据插入了当前表。

本文出自 “乔磊的博客 学习 进步” 博客

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn