我MYSQL中的数据是varchar类型的: 
1.我想原来yyyymmdd的存放格式批量修改成yyyy-mm-dd的格式,请问各位大哥们有没有什么办法. 
2.表A(a,b)  表B(a,c,d)  
  我现在想在B中增加一列b, 
  有没有办法,按照表A中a b 的关系批量的在表B中插入b的内容 

解决方案 »

  1.   

    贴记录及要求结果出来看看
    1、update tt set f1=concat(mid(f1,1,4),'-',mid(f1,5,2),'-',mid(f1,7,2))
    2
    select b.*,a.b from b left join a on a.id=b.id
      

  2.   

    or
    2
    create table b as
    select b.*,a.b from b left join a on a.id=b.id 
      

  3.   

    多谢楼上的大哥,万分感激啊
    不过第2个问题好象不是我想要的
      我是想在表B中增加一列b,同时把他在a表中的数据导入过来
      

  4.   

    2.
    alter table B add column b ....;
    update A,B set B.b=A.b where A.a=B.a;
    两步搞定
      

  5.   

    1、首先要你保证你的VARCHAR字符长度够,因为UPDATE后比原来字符数多了两个。
    具体语句。update tablename set field1 = date_format(field1+0,'%Y-%m-%d');
    2、假设要增加的列类型为INT。alter table B add b int not null default 0;
    update B,A set B.b = A.b where A.a = B.a;
      

  6.   

    注意:B字段与A表的B字段类型、长度一致
    alter table B add b int not null default 0; update B,A set B.b = A.b where A.a = B.a;
      

  7.   

    alter table B add b int not null default 0; 
    update B inner jon A on A.a = B.a;  set B.b = A.b ;
      

  8.   

    上面的那句写错了,应该少一个分号,修正后如下:alter table B add b int not null default 0; 
    update B inner jon A on A.a = B.a set B.b = A.b ;
      

  9.   

    上面的那句写错了,应该少一个分号,修正后如下:alter table B add b int not null default 0; 
    update B inner jon A on A.a = B.a set B.b = A.b ;