Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i want to put two fields in one field

Status
Not open for further replies.

MdVries

Programmer
Apr 16, 2003
47
NL
i want to put two fields in one field

code is:
Aanhef.dear_desc + Persoon.dsp_naam AS TEST

my result is this:
"dear john "

i want my result to be:
"dear john"

how can i do that?

i have tryed:
LEFT(Aanhef.dear_desc,LEN(Aanhef.dear_desc)) + Persoon.dsp_naam AS TEST

but with the same results
 
If you use it in SELECT you must PAD the result. You will get a weird result if the first record contans has a smaller length, and you didn't pad it

Code:
SELECT PADR(ALLT(Aanhef.dear_desc) ;
    + [ ] ;
    + ALLT(Persoon.dsp_naam), 80) ...

Borislav Borissov
 
SELECT PADR(Aanhef.dear_desc) - ALLT(Persoon.dsp_naam), 80) ...

The "-" operator removes the spaces before concatenating two strings so you'll get "dearjohn" from this. You need an extra space. There's also a missing "(". Try:
Code:
SELECT PADR((Aanhef.dear_desc) - (" " + ALLT(Persoon.dsp_naam)), 80) ...

Geoff Franklin
 
Hi MdVries!

Nobody explained, why
LEFT(Aanhef.dear_desc,LEN(Aanhef.dear_desc)) + Persoon.dsp_naam AS TEST
does not work.

LEN(field) is always the field length, it does count the spaces too, so this call of LEFT() really didn't cut anything from the string.

The - operation on strings is very good in such situations. If you use the Foxtools FLL you can also call REDUCE().

I'd always pad to the length of both fields+1, if that does not exceed the limit of 254 for char fields.
In this situation, where you adress people in letters or emails, 80 chars may be sufficient.

Code:
SELECT PADR(Aanhef.dear_desc - (" " + Persoon.dsp_naa),80) ...

or by using Reduce:
Code:
SELECT PADR(Reduce(Aanhef.dear_desc + Persoon.dsp_naa),80) ...

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top