Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Location
    New York, NY
    Posts
    225

    Unanswered: MySQL - Combining Fields

    Why is it when I run this SQL String against a MS SQL db it works fine:

    Code:
    "SELECT USERLNAM + ' ' + USERFNAM + ' ' + Title, USRNUM "
    FROM USER_TABLE;"
    But when I run it against a MySQL DB I get a zero value for the "USERLNAM + ' ' + USERFNAM + ' ' + Title".

    if I run the following SQL String against the MySQL DB it works fine:


    Code:
    "SELECT USERLNAM, USRNUM "
    FROM USER_TABLE;"
    How do I write this SQL String so that is works with both DB?

    I am using ADO and VB6 to connect to both DB.

  2. #2
    Join Date
    May 2003
    Location
    New York, NY
    Posts
    225
    think I found the answer to my question the CONCAT Function

    Code:
    "SELECT CONCAT(USERLNAM, ', ', USERFNAM, ', ', Title), USRNUM "
    FROM USER_TABLE;"
    But I don't have a MS SQL DB available to check and see if this function willl work with it. Can anyone advise?

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you cannot use the same sql statement on both of those database systems

    they are just flat out not syntax compatible for concatenation
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    May 2003
    Location
    New York, NY
    Posts
    225

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •