Skip to main content
Known Participant
October 8, 2008
Question

SQL statement - simple

  • October 8, 2008
  • 3 replies
  • 348 views
Hi, I know this is simple but I'm being a bit thick

I have these two columns (firstname, lastname) in the same table, I would like to join them and call it wholeName.

So I thought it was this "SELECT firstname, lastname AS wholeName FROM table"

but it doesn't work.....am I not correct?

Cheers in advance
    This topic has been closed for replies.

    3 replies

    Inspiring
    October 8, 2008
    simbull wrote:
    > many thanks ian
    >
    > so I do want a space, so it would be
    >
    > SELECT firstname + ' ' + lastname AS wholeName

    Assuming that + is your concatenation character, then yes that is how
    you would add a space.

    I presume this has worked for you by now.
    Known Participant
    October 8, 2008
    many thanks ian

    so I do want a space, so it would be

    SELECT firstname + ' ' + lastname AS wholeName

    ?
    Inspiring
    October 8, 2008
    simbull wrote:
    > Hi, I know this is simple but I'm being a bit thick
    >
    > I have these two columns (firstname, lastname) in the same table, I would like
    > to join them and call it wholeName.
    >
    > So I thought it was this "SELECT firstname, lastname AS wholeName FROM table"
    >
    > but it doesn't work.....am I not correct?
    >
    > Cheers in advance
    >

    No you are not correct. You need a concatenation character in there.
    What character that is will depend on your database. Here are two very
    common ones || and +

    I.E.
    SELECT firstname || lastname AS wholeName

    OR

    SELECT firstname + lastname AS wholeName

    If this is for display purposes you may want to also concatenate a space
    character ' ' into your result.