![](/img/trans.png)
[英]SQL where condition is only receiving one word from the value of the field
[英]Import into MySQL from SQL file, but only rows where field = value
有没有一种方法可以从/ usr / bin / mysql或/ usr / bin / mysqlimport导入sql文件,但排除特定字段没有特定值的所有行?
我想从备份中还原数据,但只还原字段“ origin”具有值“ import”的备份数据。 因此,我有一个脚本,该脚本首先删除活动数据库“ where origin ='import'”中的所有行,然后我想从文件中导入我备份的所有行,但不是每行,因为还有其他行备份中的来源。
我要说清楚吗? 有任何想法吗?
两个想法:
通过在每个语句中添加where子句来准备sqlfile。 使用您喜欢的脚本语言应该相对容易。
对于每个表,导入到临时“模式”:
insert into realtable select * from temptable where origin = 'import';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.