UPDATE mytable SET mycolumn= LTRIM(RTRIM(mycolumn));
works fine on trimming columns removing trailer spaces, but how can i adjust it to trim all column
You can use PHP for it ( in order to avoid sql errors, better print queries then execute them later ) :
$dbHost = 'localhost';
$dbUsername = 'root';
$dbPassword = '';
$dbName = 'database';
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
$db->set_charset("utf8");
$queries = '';
$query="SELECT * from table";
$result = $db->query($query);
$headers = $result->fetch_fields();
foreach($headers as $header) {
$col = $header->name;
$queries .= "UPDATE table SET `".$col."` = TRIM(`".$col."`) ";
}
echo $queries;
?>