concatenating fields in an SQL query

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

  • Next message: Pierre Roux: "Re: TADOQuery memory leak?"
    Date: Thu, 17 Feb 2005 16:39:22 +0100
    
    

    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

    I'm working with MsAccess db and Delphi 6 and ADO
    In access I have defined the fields as follow:
    FirstName, Text 10, Required = No, Allow Zero Length = Yes
    MiddleName, Text 10, Required = No, Allow Zero Length = Yes
    LastName, Text 10, Required = Yes, Allow Zero Length = No

    Thanks in advance,
    Willy


  • Next message: Pierre Roux: "Re: TADOQuery memory leak?"

    Relevant Pages