str_to_date和concat到单位日期和时间

时间:2016-10-25 09:22:49

标签: mysql

str_to_date和concat将函数与时间和日期联合起来。我不知道如何更改要导入的格式,或者在访问后直接填充或填充。

CREATE trigger `trigger` before insert
    on `int`
    for each row


BEGIN

    declare p, c, v, m, dublare int;
    declare dublare_inreg condition for 1062;
    declare continue handler for dublare_inreg
        begin
            set dublare = 0;    
        end;
    set dublare = 1;
    set foreign_key_checks = 0;



    insert into pacienti(nume,prenume) values(new.numepacient,new.prenumepacient);      

        set p = last_insert_id();
        if dublare = 0 then
            select distinct id_p from pacienti where nume = new.numepacient into p;
            set dublare = 1;

        end if;

    insert into cabinete(den_cabinet) values(new.cabinet);              

        set c = last_insert_id();
        if dublare = 0 then
            select distinct id_c from cabinete where den_cabinet =new.cabinet into c;
            set dublare = 1;

        end if;

        set m = last_insert_id();
      if dublare = 0 then
        select distinct id_m from medici where id_m = nume into m;
            set dublare = 1;
      end if;

    INSERT INTO vizite(data_ora,id_cabinet,id_pacienti,id_medici) 
        values(str_to_date(new.datavizita, ' ' , new.oraintrare, '%d / %m / %Y %H:%i:%s')), p , c , m); 

在我的csv文件中,我有格式数据22/02/2016

这是我的负担。

  load data local infile 'D:\\pfinal\\vizite.txt' IGNORE into table `int` 
                                fields terminated by ','
                                lines terminated by '\n'
                                ignore 190000 lines
                                (DataVizita,OraIntrare,NumePacient,PrenumePacient,NumeMedic,PrenumeMedic,Cabinet)
                            ;  

1 个答案:

答案 0 :(得分:0)

删除日期格式的空格,它们在输入日期不存在,并使用CONCAT合并日期和时间字段

str_to_date(CONCAT(new.datavizita,' ',new.oraintrare),'%d/%m/%Y %H:%i:%s')