Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.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 - Fatal编程技术网

如何在Mysql中找到带回车符的列?

如何在Mysql中找到带回车符的列?,mysql,Mysql,我是SQL的初学者,尝试运行如下查询: select id from "a_table" where col_value = 'ABCDEF'; 现在在表a\u表中,col\u值既有 'ABCDEF' 及 (带回车) 我的问题是如何构造我的查询,以便如果我在表中搜索'ABCDEF',其中ABCDEF存在,并且可能有回车符,也可能没有回车符。尝试使用replace函数 select id from "a_table" where replace(replace(col_value, '\r',

我是SQL的初学者,尝试运行如下查询:

select id from "a_table" where col_value = 'ABCDEF';
现在在表
a\u表中,
col\u值既有

'ABCDEF'

(带回车)


我的问题是如何构造我的查询,以便如果我在表中搜索
'ABCDEF'
,其中ABCDEF存在,并且可能有回车符,也可能没有回车符。

尝试使用
replace
函数

select id
from "a_table"
where replace(replace(col_value, '\r', ''), '\n', '') = 'ABCDEF'
如果需要,可以更新
bad

update "a_table"
set
  col_value = replace(replace(col_value, '\r', ''), '\n', '')
where col_value <> replace(replace(col_value, '\r', ''), '\n', '')
更新“a_表”
设置
col_值=替换(替换(col_值,'\r','','\n','')
其中col_值替换(替换(col_值,'\r','','','\n','')
但在更新之前,最好使用以下查询检查它们

select
  id,
  col_value,
  replace(replace(col_value, '\r', ''), '\n', '') new_value
from "a_table"
where col_value <> replace(replace(col_value, '\r', ''), '\n', '')
选择
身份证件
col_值,
替换(替换(列值,'\r',''),'\n','')新的列值
从“a_表”
其中col_值替换(替换(col_值,'\r','','','\n','')

尝试使用
replace
功能

select id
from "a_table"
where replace(replace(col_value, '\r', ''), '\n', '') = 'ABCDEF'
如果需要,可以更新
bad

update "a_table"
set
  col_value = replace(replace(col_value, '\r', ''), '\n', '')
where col_value <> replace(replace(col_value, '\r', ''), '\n', '')
更新“a_表”
设置
col_值=替换(替换(col_值,'\r','','\n','')
其中col_值替换(替换(col_值,'\r','','','\n','')
但在更新之前,最好使用以下查询检查它们

select
  id,
  col_value,
  replace(replace(col_value, '\r', ''), '\n', '') new_value
from "a_table"
where col_value <> replace(replace(col_value, '\r', ''), '\n', '')
选择
身份证件
col_值,
替换(替换(列值,'\r',''),'\n','')新的列值
从“a_表”
其中col_值替换(替换(col_值,'\r','','','\n','')

这可以解决您的问题

select id from "a_table" where replace(col_value,'\n','') = 'ABCDEF';

这可以解决你的问题

select id from "a_table" where replace(col_value,'\n','') = 'ABCDEF';

要检索不带回车符的数据,请尝试

    select id from "a_table" where col_value = 'ABCDEF' and col_value NOT REGEXP "\r\n";

要检索不带回车符的数据,请尝试

    select id from "a_table" where col_value = 'ABCDEF' and col_value NOT REGEXP "\r\n";

其中col_值如“ABCD%”;谢谢但问题是我不知道回车的确切位置;谢谢但问题是我不知道回车的确切位置。谢谢大家,使用替换功能解决了这个问题。正如Leran2002所指出的,更新表是下一个任务。谢谢大家,使用replace函数解决了这个问题。正如Leran2002所指出的,更新表是下一个任务。