Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Removing spaces from query results

by choroba (Chancellor)
on Apr 30, 2013 at 14:08 UTC ( #1031410=note: print w/ replies, xml ) Need Help??

in reply to Removing spaces from query results

I would use LTRIM(RTRIM(...)) on the SQL side.

لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Comment on Re: Removing spaces from query results
Download Code
Replies are listed 'Best First'.
Re^2: Removing spaces from query results
by Anonymous Monk on Apr 30, 2013 at 14:11 UTC
    I did but it doesn't work <code>..RTRIM(LTRIM(name)) as name..." I have to do it in the Perl.
      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"; }


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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031410]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2016-02-09 00:12 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (291 votes), past polls