Assuming you have already inserted these values into the table, you may trim them of their space characters.
Assuming also that the columns in the table are called c1
, c2
and c3
:
UPDATE x SET c1 = TRIM(c1), c2 = TRIM(c2), c3 = TRIM(c3);
The TRIM()
function will remove both leading and trailing spaces.
If you want to test this on a temporary table first:
CREATE TEMPORARY TABLE t AS SELECT * FROM x;
UPDATE t SET c1 = TRIM(c1), c2 = TRIM(c2), c3 = TRIM(c3);
SELECT * from t;
... or just
SELECT TRIM(c1), TRIM(c2), TRIM(c3) FROM x;
which wouldn't change anything in the database at all.
An SQL tip: When inserting values, do mention the names of the columns:
INSERT INTO x (c1, c2, c3) VALUES ('a', 'b', 'c');
This both serves as documentation and allows you to change the schema of the table (inserting new columns or rearranging columns) without having to hunt down and change every INSERT
statement in your code.
(
orvalues(
in the line,awk
would be good choice... or you can useperl
to perform substitution on string that is matched...