测试语句  CREATE TABLE IF NOT EXISTS `user1` (   
    `id` int(11) NOT NULL AUTO_INCREMENT,   
    `name` varchar(50) DEFAULT NULL,   
   `sex` int(1) NOT NULL DEFAULT '0',   
   PRIMARY KEY (`id`)   
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;   
 
  -- select * from   user1


 CREATE TABLE IF NOT EXISTS `user2` (   
   `id` int(11) NOT NULL AUTO_INCREMENT,   
   `name` varchar(50) DEFAULT NULL,   
   `sex` int(1) NOT NULL DEFAULT '0',   
   PRIMARY KEY (`id`)   
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;   
 
 --   select * from   user2
 
 INSERT INTO `user1` (`name`, `sex`) VALUES('张映', 0);
 INSERT INTO `user2` (`name`, `sex`) VALUES('tank', 1);   
 
 
 
 
 
     CREATE TABLE IF NOT EXISTS `alluser` (   
    `id` int(11) NOT NULL AUTO_INCREMENT,   
    `name` varchar(50) DEFAULT NULL,   
    `sex` int(1) NOT NULL DEFAULT '0',   
    INDEX(id)   
  ) TYPE=MERGE UNION=(user1,user2) INSERT_METHOD=LAST AUTO_INCREMENT=1 ;  
 
select id,name,sex from  alluser

 
select id,name,sex from  alluser错误信息  MySQL Database Error: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist

解决方案 »

  1.   

    补充MYSQL版本信息MySQL Server 5.1
      

  2.   

    贴出你的show create table user1;
    show create table user2;
    show create table alluser;
      

  3.   


         CREATE TABLE IF NOT EXISTS `alluser` (   
        `id` int(11) ,   
        `name` varchar(50) DEFAULT NULL,   
        `sex` int(1) NOT NULL DEFAULT '0',   
        INDEX(id)   
      ) TYPE=MERGE UNION=(user1,user2) INSERT_METHOD=LAST AUTO_INCREMENT=1 ;  你试试
      

  4.   

    最后1句
     显示错误  信息如下MySQL Database Error: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
      

  5.   


    试过 还是这个错误  再补充 我是本机电脑自己装的MYSQL
      

  6.   

    connect to search for the answer 
    thx
      

  7.   

    CREATE TABLE IF NOT EXISTS `alluser` (   
    `id` int(11) NOT NULL AUTO_INCREMENT,   
    `name` varchar(50) DEFAULT NULL,   
    `sex` int(1) NOT NULL DEFAULT '0',   
    INDEX(id)   
    ) ENGINE=MERGE UNION=(user1,user2) DEFAULT CHARSET=utf8 INSERT_METHOD=LAST ;  
    你的字符集没有设置! 改成如上即可。
    mysql>      CREATE TABLE IF NOT EXISTS `alluser` (
        ->     `id` int(11) NOT NULL AUTO_INCREMENT,
        ->     `name` varchar(50) DEFAULT NULL,
        ->     `sex` int(1) NOT NULL DEFAULT '0',
        ->     INDEX(id)
        ->   ) ENGINE=MERGE UNION=(user1,user2) DEFAULT CHARSET=utf8 INSERT_METHOD=L
    AST ;
    Query OK, 0 rows affected (0.16 sec)mysql> select id,name,sex from  alluser;
    +----+------+-----+
    | id | name | sex |
    +----+------+-----+
    |  1 | 张映 |   0 |
    |  1 | tank |   1 |
    +----+------+-----+
    2 rows in set (0.00 sec)mysql>