我有两个不同的表,由Load DATA命令创建,我正在尝试运行以下代码:
select t.name as Name, sum(t.amount) as Total from
(select t2.name, t1.vendorname, t1.amount from bco_ifs_payment_data t1
join VendorName t2 on t1.vendorname like concat('%',t2.name,'%' )) as t
group by t.name;
当我使用INSERT INTO命令将数据插入VendorName表时,代码工作并返回行,但是当我使用LOAD DATA命令在VendorName表中插入数据时,即使插入了相同的数据,也不会在JOIN中返回任何行在表格中
Vendor_Names CSV只有一列。 LOAD数据查询如下:
create Table vendorname(name nvarchar(100));
LOAD DATA LOCAL INFILE 'F:\Payments\_Global Payment\\Data\\Data\\Vendor_Names.csv'
INTO TABLE vendorname FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';
update vendorname SET name = UPPER(name);
INSERT查询如下:
INSERT INTO vendorname VALUES ('DELOITTE');
INSERT INTO vendorname VALUES ('CBRE');
答案 0 :(得分:0)
你可以发布两个查询,可能是csv中的值序列与插入查询的内容不同
答案 1 :(得分:0)
知道了,必须包含以下代码:
select t.name as Name, sum(t.amount) as Total from
(select t2.name, t1.vendorname, t1.amount from bco_ifs_payment_data t1
join vendorname t2 on t1.vendorname like concat('%',REPLACE(t2.name,'\r','') ,'%' )) as t
group by t.name;