in reply to Re: Removing spaces from query results
in thread Removing spaces from query results

I did but it doesn't work <code>..RTRIM(LTRIM(name)) as name..." I have to do it in the Perl.
  • Comment on Re^2: Removing spaces from query results

Replies are listed 'Best First'.
Re^3: Removing spaces from query results
by choroba (Cardinal) on Apr 30, 2013 at 14:20 UTC
    Strange. Works for me:
    #!/usr/bin/perl use warnings; use strict; use DBI; my $db = DBI->connect('dbi:SQLite:dbname=1.db', q(), q()); $db->do('CREATE TABLE T (name varchar)'); my $insert = $db->prepare('INSERT INTO T VALUES(?)'); for my $name (qw(Matthew Mark Luke John)) { $insert->execute((' ' x rand 10) . $name . (' ' x rand 10)); } my $select = $db->prepare('SELECT LTRIM(RTRIM(name)) AS name FROM T'); $select->execute; while (my $name = $select->fetchrow_arrayref) { print "|$name->[0]|\n"; }

    Output:

    |Matthew| |Mark| |Luke| |John|
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ