有两个表
都有item_type字段 其他的字段有些相同 有些不同由于要对应插入的字段实在是太多 不想一个一个对照着写下去 请问各位大侠有什么好的解决方法

解决方案 »

  1.   

    一般插入记录则可以insert into table2 select * from table1;更新则update table1 inner join talbe2 on table1.col=table2.col
    set table1.coln=talbe2.coln
      

  2.   

    没有办法,只有一个一个地写
    inser into tt(f1,f2,f3) select f2,f3,f1 from tt1
      

  3.   

    如果是这样 insert into table1 (col1,col2,...coln) from select col1,col2,...coln from table1;
    则没什么好办法。一般是直接先把所有列DESC出来,然后贴到EXCEL中,再字处理一下。
      

  4.   

    mysql> select * from text;
    +----+-------+------------+
    | id | value | articles   |
    +----+-------+------------+
    |  1 | aaa   | 1-2,4-9,37 |
    |  2 | bbb   | 23,80      |
    |  3 | ccc   | 1-24       |
    +----+-------+------------+
    3 rows in set (0.00 sec)mysql> select * from test;
    +----+-------+---------+-----+
    | id | class | name    | age |
    +----+-------+---------+-----+
    |  1 | A     | aaa     | 20  |
    |  2 | A     | bbb     | 25  |
    |  3 | B     | ddd     | 30  |
    |  4 | C     | sss     | 40  |
    |  5 | B     | sssffff | 50  |
    |  6 | A     | rrr     | 33  |
    |  7 | A     | eee     | 15  |
    |  8 | B     | www     | 55  |
    |  9 | C     | hhh     | 22  |
    +----+-------+---------+-----+
    9 rows in set (0.00 sec)mysql> insert into test select null,value,articles,10 from text;
    Query OK, 3 rows affected (0.02 sec)
    Records: 3  Duplicates: 0  Warnings: 0mysql> select * from test;
    +----+-------+------------+-----+
    | id | class | name       | age |
    +----+-------+------------+-----+
    |  1 | A     | aaa        | 20  |
    |  2 | A     | bbb        | 25  |
    |  3 | B     | ddd        | 30  |
    |  4 | C     | sss        | 40  |
    |  5 | B     | sssffff    | 50  |
    |  6 | A     | rrr        | 33  |
    |  7 | A     | eee        | 15  |
    |  8 | B     | www        | 55  |
    |  9 | C     | hhh        | 22  |
    | 10 | aaa   | 1-2,4-9,37 | 10  |
    | 11 | bbb   | 23,80      | 10  |
    | 12 | ccc   | 1-24       | 10  |
    +----+-------+------------+-----+
    12 rows in set (0.00 sec)
    mysql> update test set age=15 where id=10;
    Query OK, 1 row affected (0.03 sec)
    Rows matched: 1  Changed: 1  Warnings: 0其中10这个constant就是两表之间不同值的列 要你自己进行update的