gpt4 book ai didi

mysql - str_to_date 并连接到单位日期和时间

转载 作者:行者123 更新时间:2023-11-30 22:10:36 25 4
gpt4 key购买 nike

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)
;

最佳答案

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

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

关于mysql - str_to_date 并连接到单位日期和时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40236143/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com