If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Con Cat In Ate

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-09-06, 11:45
dansrobe dansrobe is offline
Registered User
 
Join Date: Jan 2004
Posts: 11
Question Con Cat In Ate

I have a first name and a last name, in two different fields. I use a simple bit of SQL to show them together.

SELECT
{fn concat(dbo.table_employee.first_name , dbo.table_employee.last_name)}
FROM
dbo.table_employee

Gives me results like BradWilliams and DarWilliams and such.

Simple enough. But, it would be nice to put a space between first name and last name. And that is sending me for a loop. Any advise?

Thanks,
Dan
Reply With Quote
  #2 (permalink)  
Old 01-09-06, 11:54
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,246
Dan
why do it at SQL level - do it at the presentation / UI level, unless you have a direct need - ie the export from the SQL goes to another process.

how do you handle null forenames. depending on the SQL engine you are using you could write a function to do this.
Reply With Quote
  #3 (permalink)  
Old 01-09-06, 14:09
Ida Hoe Ida Hoe is offline
Registered User
 
Join Date: Aug 2003
Location: West
Posts: 98
Con Cat In Ate

SELECT
{fn concat (dbo.table_employee.first_name,
{fn concat (' ', dbo.table_employee.last_name)})}
FROM
dbo.table_employee
Reply With Quote
  #4 (permalink)  
Old 01-09-06, 16:32
dansrobe dansrobe is offline
Registered User
 
Join Date: Jan 2004
Posts: 11
Perfect, Ida, that got it, thank you
Reply With Quote
  #5 (permalink)  
Old 01-10-06, 03:16
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,246
I wouldn't go so far as 'perfect'
say Fname= "Dan", SName="Srobe"
SQL returns: "Dan_Srobe"
say Fname= SName="Dansrobe"
SQL returns: "_Dansrobe", when I'm guessing you would want "Dansrobe" with no space "_".
It becomes more of a problem if you want to build a name from say Title,FName,SName,Qualifications where you could end up with
"__Dansrobe_"

still if it works appropriately then maybe it is "perfect" after all.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On