Concat two fields in SQL

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Concat two fields in SQL

    I am trying to concatenate two columns in an SQL statement but haven't been
    having much success: here is the portion of the SQL: CONCAT(people_lname||'
    '||people_fname) as Person

    Is this correct syntax?

    Reading through one of my oracle books it seems to be the correct syntax but
    not sure if CF likes it.

    thomascraig Guest

  2. Similar Questions and Discussions

    1. Which version supports concat???
      I have a problem with different versions of MySQL supporting concat differently. The portion of the query that uses the concat function looks...
    2. Concat problem with SQL
      hi all I have a problem when I try to concat 2 fields with a dot, in a query (Oracle database). here an example : <query name="myquery"...
    3. concat fields then search the new field
      how would I concatenate several fields from a record set then search the new field for individual keywords ? something like: Dim theArray ...
    4. php string concat
      Hello, Simple question here.... I am trying to concatenate 2 strings but it doesn't seem to work. My only experience in in C and VB 6.0. ...
    5. dropdownlist-concat two fields-can it be done
      I am not sure how to, or even if you can do this. I have tried several things. I have a drop down list that is databound to a datareader. I wish...
  3. #2

    Default Re: Concat two fields in SQL

    What database are you using? With Oracle you would use || as the concatenation
    operator (without the CONCAT), but for SQL Server or Access you would use + as
    in

    people_lname +' '+ people_fname as Person

    Phil


    paross1 Guest

  4. #3

    Default Re: Concat two fields in SQL

    I'm using an Oracle db, I tried your suggestion without any luck.
    thomascraig Guest

  5. #4

    Default Re: Concat two fields in SQL

    Phil,

    Just remembered I'm using SQL Server in my testing environment - oracle in production. Your suggestion worked.
    thomascraig Guest

  6. #5

    Default Re: Concat two fields in SQL

    You're using SQL Server in testing and Oracle in development? You realize that all of your testing is suspect, right?
    Dan Bracuk Guest

  7. #6

    Default Re: Concat two fields in SQL

    If you are using SQL Server in develoment, and Oracle in production, and you
    have lot of SQL, it is going to be a minefield of little syntax and function
    differences even if you closely adhere to "standard" ANSI SQL 92, and you will
    constantly have to make many many changes when migrating your development code
    into production. A very bad idea. I know that Oracle is expensive but couldn't
    your DBA create a small instance for you to do your development and testing?

    Phil

    paross1 Guest

  8. #7

    Default Re: Concat two fields in SQL

    Doesn't Oracle have a free edition, Oracle express, just for situations like this?


    MikerRoo Guest

  9. #8

    Default Re: Concat two fields in SQL

    Yup. Never used it, but it sounds like it would be much better than SQL server
    for dev, and Oracle for production!

    [url]http://www.oracle.com/technology/products/database/xe/index.html[/url]

    Oracle Database 10g Express Edition (Oracle Database XE) is an entry-level,
    small-footprint database based on the Oracle Database 10g Release 2 code base
    that's free to develop, deploy, and distribute; fast to download; and simple to
    administer. Oracle Database XE is a great starter database for:

    Developers working on PHP, Java, .NET, and Open Source applications
    DBAs who need a free, starter database for training and deployment
    Independent Software Vendors (ISVs) and hardware vendors who want a starter
    database to distribute free of charge
    Educational institutions and students who need a free database for their
    curriculum


    Phil

    paross1 Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139