Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

SQL statement - simple

Explorer ,
Oct 08, 2008 Oct 08, 2008
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
322
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 08, 2008 Oct 08, 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 08, 2008 Oct 08, 2008
many thanks ian

so I do want a space, so it would be

SELECT firstname + ' ' + lastname AS wholeName

?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 08, 2008 Oct 08, 2008
LATEST
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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources