Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MYSQL加载数据填充_Mysql_Null_Load Data Infile - Fatal编程技术网

MYSQL加载数据填充

MYSQL加载数据填充,mysql,null,load-data-infile,Mysql,Null,Load Data Infile,我在mysql中使用加载数据填充。在我的输入文件中,我有“x”字符,但我必须将其作为NULL保存到数据库中。我怎么做 load data infile... into table ... fields terminated by... lines terminated by ... ( my_field... ) set my_field = if(my_field = 'x', null, my_field); 多亏了佩卡 多亏了pekka,它非常有用,但它首先将x指定为date,然后

我在mysql中使用加载数据填充。在我的输入文件中,我有“x”字符,但我必须将其作为NULL保存到数据库中。我怎么做

load data infile... 
into table ...
fields terminated by...
lines terminated by ...
(
 my_field...
)
set 
my_field = if(my_field = 'x', null, my_field);
多亏了佩卡


多亏了pekka,它非常有用,但它首先将x指定为date,然后更改为null。这违反了“日期不能是‘x’”的规定,嗯??在加载时,它会检查my_字段的值。如果它是“x”,它将写入一个空值,否则它将写入原始值。哦,它是一个日期字段-如果您之前提到过,它将非常有用!它非常有用,但它首先将x指定为date,然后更改为null。这违反了“日期不能是‘x’”的规定,嗯??在加载时,它会检查my_字段的值。如果它是“x”,它将写入一个空值,否则它将写入原始值。哦,它是一个日期字段-如果您之前提到过,它将非常有用!
load data infile... 
into table ...
fields terminated by...
lines terminated by ...
(
 @var...
)
set 
my_field = if(@var = 'x', null, @var);