I have run cat -v on a file, see ^K where I was expecting to see some kind of whitespace, but don't know how to translate that code into something I can use to find and replace the character in MySQL.
Context: I have a mysql field that appears to have a newline at the end, as when I query it, the output wraps around.
select t_unid_contact , concat('"',t_phone,'"') , t_phone from contacts_june_2013 where T_UNID_Contact = 'CN726181'; +----------------+-------------------------+-------------+ | t_unid_contact | concat('"',t_phone,'"') | t_phone | +----------------+-------------------------+-------------+ | CN726181 | "4155551212 " | 4155551212 | +----------------+-------------------------+-------------+ 1 row in set (0.00 sec)
I tried these WHERE clauses, to try to identify rows with the hidden character, but got no results:
where t_phone like '%\n%' where t_phone like '%\r%' where t_phone like '%\r\n%' where t_phone like '%\k%' where t_phone regexp '[\r]' where t_phone regexp '[\k]' where t_phone regexp '[\n]' where t_phone regexp '[\r\n]'
I output a problem row into a csv and ran this to look at it; here is the output:
cat -v testwhitespace.csv "CN726181","4155551212^K"
Does anyone know how I can identify that whitespace character in my table, in such a way that I can use replace() to get rid of it?
Thanks