mysql 两张数据表导入问题

黑猫警长-ZX php高级工程师  2014-01-03 09:41:07
我有两张表,一个表 z_hzmanage,另一个表是:z_hzmanage_new ,我想将z_hzmanage表数据导入到z_hzmanage_new这个新表里面。用什么办法导入啊

z_hzmanage表结构:

/*
Navicat MySQL Data Transfer

Source Server : localhost_3306
Source Server Version : 50045
Source Host : localhost:3306
Source Database : zond_lm

Target Server Type : MYSQL
Target Server Version : 50045
File Encoding : 65001

Date: 2014-01-03 09:37:58
*/

SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `z_hzmanage`
-- ----------------------------
DROP TABLE IF EXISTS `z_hzmanage`;
CREATE TABLE `z_hzmanage` (
`z_id` int(11) NOT NULL auto_increment,
`z_yyh` char(25) NOT NULL,
`z_uname` char(10) NOT NULL,
`z_sex` int(10) unsigned NOT NULL default '0',
`z_age` varchar(10) default '0',
`z_area` int(15) unsigned NOT NULL default '0',
`z_tel` varchar(15) default NULL,
`z_mzbz1` varchar(30) default NULL,
`z_mzbz2` varchar(30) default NULL,
`z_jzbz1` varchar(30) default NULL,
`z_jzbz2` varchar(30) default NULL,
`z_dzdate` varchar(30) default NULL,
`z_yydate` varchar(30) default NULL,
`z_isxf` int(5) unsigned NOT NULL default '0',
`z_source` int(10) unsigned NOT NULL default '0',
`z_jzys` int(10) unsigned NOT NULL default '0',
`z_ks` varchar(10) default '0',
`z_hfyx` int(5) unsigned default '0',
`z_isask` int(5) unsigned NOT NULL default '0',
`z_askcontent` text,
`z_askdate` varchar(30) default NULL,
`z_bzcontent` text,
`z_content` text,
`z_isstate` int(5) unsigned NOT NULL default '0',
`z_class` int(10) unsigned NOT NULL default '0',
`z_username` varchar(10) default NULL,
`z_hfuname` varchar(10) default NULL,
`z_systemdate` datetime NOT NULL default '0000-00-00 00:00:00',
`z_Recycle` int(5) unsigned NOT NULL default '0',
PRIMARY KEY (`z_id`)
) ENGINE=InnoDB AUTO_INCREMENT=8965 DEFAULT CHARSET=gbk;

-- ----------------------------
-- Records of z_hzmanage
-- ----------------------------




z_hzmanage_new表结构:
/*
Navicat MySQL Data Transfer

Source Server : localhost_3306
Source Server Version : 50045
Source Host : localhost:3306
Source Database : zond_lm

Target Server Type : MYSQL
Target Server Version : 50045
File Encoding : 65001

Date: 2014-01-03 09:33:44
*/

SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `z_hzmanage_new`
-- ----------------------------
DROP TABLE IF EXISTS `z_hzmanage_new`;
CREATE TABLE `z_hzmanage_new` (
`z_id` int(10) NOT NULL auto_increment COMMENT '主键自增',
`z_yyh` char(12) NOT NULL COMMENT '预约号',
`z_uname` char(20) NOT NULL COMMENT '患者姓名',
`z_sex` tinyint(1) NOT NULL default '0' COMMENT '性别',
`z_age` tinyint(2) NOT NULL default '0' COMMENT '年龄',
`z_area` smallint(2) NOT NULL default '0' COMMENT '一级城市',
`z_area2` smallint(2) NOT NULL default '0' COMMENT '二级城市',
`z_tel` char(15) NOT NULL COMMENT '电话号码',
`z_jzbz1` char(50) NOT NULL COMMENT '咨询病种1',
`z_jzbz2` char(50) NOT NULL COMMENT '咨询病种2',
`z_mzbz1` char(50) NOT NULL default '' COMMENT '门诊病种1',
`z_mzbz2` char(50) NOT NULL default '' COMMENT '门诊病种2',
`z_yydate` date NOT NULL default '0000-00-00' COMMENT '预约时间',
`z_pm` tinyint(2) NOT NULL default '0',
`z_dzdate` date NOT NULL default '0000-00-00' COMMENT '到诊时间',
`z_isxf` tinyint(2) NOT NULL default '0' COMMENT '是否消费',
`z_source` tinyint(2) NOT NULL default '0' COMMENT '患者来源',
`z_ks` char(8) NOT NULL default '' COMMENT '科室',
`z_jzys` tinyint(2) NOT NULL default '0' COMMENT '就诊医生',
`z_isask` tinyint(1) NOT NULL default '0' COMMENT '是否回访',
`z_hfyx` tinyint(1) NOT NULL default '0' COMMENT '回访意向',
`z_askdate` date NOT NULL default '0000-00-00' COMMENT '回访日期',
`z_isstate` tinyint(1) NOT NULL default '0' COMMENT '是否到诊',
`z_class` tinyint(2) NOT NULL default '0' COMMENT '邦定用户ID',
`z_username` char(8) NOT NULL COMMENT '邦定用户表',
`z_hfuname` char(8) NOT NULL default '' COMMENT '回访姓名',
`z_systemdate` datetime NOT NULL default '0000-00-00 00:00:00' COMMENT '录入时间',
`z_Recycle` tinyint(2) NOT NULL default '0' COMMENT '回收站',
`z_askcontent` text COMMENT '回访内容',
`z_bzcontent` text COMMENT '备注内容',
`z_content` text COMMENT '咨询内容',
PRIMARY KEY (`z_id`),
KEY `z_yyh` (`z_yyh`),
KEY `z_uname` (`z_uname`),
KEY `z_age` (`z_age`),
KEY `z_area` (`z_area`),
KEY `z_area2` (`z_area2`),
KEY `z_tel` (`z_tel`),
KEY `z_jzbz1` (`z_jzbz1`),
KEY `z_jzbz2` (`z_jzbz2`),
KEY `z_mzbz1` (`z_mzbz1`),
KEY `z_mzbz2` (`z_mzbz2`),
KEY `z_yydate` (`z_yydate`),
KEY `z_dzdate` (`z_dzdate`),
KEY `z_source` (`z_source`),
KEY `z_jzys` (`z_jzys`),
KEY `z_hfyx` (`z_hfyx`),
KEY `z_askdate` (`z_askdate`),
KEY `z_class` (`z_class`),
KEY `z_username` (`z_username`),
KEY `z_hfuname` (`z_hfuname`),
KEY `z_systemdate` (`z_systemdate`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=gbk;

-- ----------------------------
-- Records of z_hzmanage_new
-- ----------------------------

搞了一晚上没弄好,请各位大哥大姐帮帮忙啊!
...全文
463 点赞 收藏 1
写回复
1 条回复
xuzuning 2014年01月03日
insert into z_hzmanage_new select * from z_hzmanage 如果两表结构不同,则需开列需要的字段 insert into z_hzmanage_new (字段列表) select 字段列表 from z_hzmanage
回复 点赞
发动态
发帖子
PHP
创建于2008-08-27

8577

社区成员

1.9w+

社区内容

“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
社区公告
暂无公告