Skip to main content
Known Participant
June 8, 2006
Question

Concat two fields in SQL

  • June 8, 2006
  • 2 replies
  • 1564 views
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.
This topic has been closed for replies.

2 replies

Inspiring
June 8, 2006
You're using SQL Server in testing and Oracle in development? You realize that all of your testing is suspect, right?
Participating Frequently
June 8, 2006
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
June 9, 2006
Doesn't Oracle have a free edition, Oracle express, just for situations like this?

Participating Frequently
June 8, 2006
What database are you using? With Oracle you would use || as the concatenation operator (without the CONCAT), as in:

people_lname || ' ' || people_fname as Person

for SQL Server or Access you would use + as in:

people_lname +' '+ people_fname as Person

MySQL you might do it this way:

CONCAT(people_lname, ' ', people_fname) as Person

Phil
Known Participant
June 8, 2006
I'm using an Oracle db, I tried your suggestion without any luck.
Known Participant
June 8, 2006
Phil,

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