MySQL:将多个文件加载到表中 [英] MySQL: Loading multiple files into a table

查看:73
本文介绍了MySQL:将多个文件加载到表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图将多个文件加载到一个表中,以便它们适合同一行.

I've been trying to load multiple files into a table, so that they would fit the same row.

我可以分别插入它们,但是问题出在NULL值之内,因此我打算加入该表.如果发生这种情况,我会得到太多的NULL值-无用的数据.

I can insert them separately, but then the issue lies within the NULL values, and I plan to JOIN this table. If that happens, I get too many NULL values -- useless data.

LOAD DATA LOCAL INFILE 'malefirst.txt, femalefirst.txt, allfirst.txt, allfirst.txt' 
INTO TABLE fnames 
 (mal, fml, unk, cpx);

我实际上研究过的另一件事是将文件与

Another thing I have actually looked into was joining the files together with

paste -d " " (1.txt 2.txt ....)

但是,它变成了一团糟.如果第一种方法不起作用,那么我可以使用第二种方法,但是我也需要有关它的建议.

However, it turned into a mess. If the first method does not work, then I can use the second, but I will need advice on it as well.

推荐答案

您可以将4个文件加载到4个(临时)表中(每个表都有一个自动编号的字段),然后将这些文件加入(使用ID)到表中.

You could load the 4 files into 4 (temporary) tables (each with an autonumbered field) and then JOIN (using the ids) these files INTO your TABLE.

这篇关于MySQL:将多个文件加载到表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆