1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

field contains spaces : sql

Discussion in 'Software Development' started by cgjoker, Nov 8, 2007.

Thread Status:
Not open for further replies.
  1. cgjoker

    cgjoker Thread Starter

    Joined:
    Aug 13, 2003
    Messages:
    205
    A field may have data such as 'This is a test'.

    If I select this field within a unix for loop the result of this query is

    This
    is
    a
    test.

    How can I get it so that the result stays on one line.

    The unix code is below.

    number=`db2 -x "select distinct(number) from test"`

    for n in $number
    do
    echo "getting data for number"
    data=`db2 -x "select data from test where number= $number"`
    for d in $data
    do
    echo $d
    done
    done

    result is

    1 This
    1 is
    1 a
    1 test

    ideal results
    1 This is a test
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - field contains spaces
  1. pcloudy
    Replies:
    1
    Views:
    262
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/649413

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice