Re: concatenating fields in an SQL query

From: Willy Verbiest (willy.verbiest_at_Advantra_No_Spam.com)
Date: 02/18/05


Date: Fri, 18 Feb 2005 09:06:05 +0100

Sunil,
It works, I've changed the lines to:
  iif(isnull(tblContacts.FirstName),'',tblContacts.FirstName + ' ') +
  iif(isnull(tblContacts.MiddleName),'',tblContacts.MiddleName + ' ') +
  iif(isnull(tblContacts.LastName),'',tblContacts.LastName) as ContactName

Thanks,
Willy

"Sunil Furtado" <sunil@furtado.de> wrote in message
news:42159015@newsgroups.borland.com...
> SELECT
> tblContacts.*,
> iif(isnull(tblContacts.FirstName,' ',tblContacts.FirstName) )+ ' ' + etc
>
> Sunil
>
> ----- Original Message -----
>
>> I'm trying to concatenate 3 fields: FirstName + MiddleName + LastName to
>> get a nieuw field ContactName to select in dropdownbox.
>> If one of the 3 fields is empty i get an empty ContactName string back.
>> Here is the SQL
>>
>> SELECT
>> tblContacts.*,
>> tblContacts.FirstName + ' ' +
>> tblContacts.MiddleName + ' ' +
>> tblContacts.LastName as ContactName
>> FROM tblContacts
>> WHERE tblContacts.CustomerID = :CustomerID
>> ORDER BY LastName, FirstName
>
>



Relevant Pages

  • Re: Help With SELECT Statement
    ... SELECT ContactName, SUM ... FROM tblContacts RIGHT JOIN tblInvoices ON tblContacts.ContactID = ... SumAS SumAmount ...
    (microsoft.public.sqlserver)
  • Re: Help With SELECT Statement
    ... > SELECT ContactName, SUM ... > FROM tblContacts RIGHT JOIN tblInvoices ON tblContacts.ContactID = ... > SumAS SumAmount ...
    (microsoft.public.sqlserver)
  • Re: concatenating fields in an SQL query
    ... > get a nieuw field ContactName to select in dropdownbox. ... > If one of the 3 fields is empty i get an empty ContactName string back. ... > tblContacts.*, ...
    (borland.public.delphi.database.ado)
  • concatenating fields in an SQL query
    ... I'm trying to concatenate 3 fields: FirstName + MiddleName + LastName to get ... If one of the 3 fields is empty i get an empty ContactName string back. ... FROM tblContacts ... MiddleName, Text 10, Required = No, Allow Zero Length = Yes ...
    (borland.public.delphi.database.ado)
  • Re: How do I find duplicates in Access 2002 without the install cd-rom
    ... SELECT ContactName, Countas NumOf ... FROM tblContacts ... MS Access MVP ...
    (microsoft.public.access.queries)