Re: [Q] String Concatination
Posted in 1998
Richard Hurt wrote: > > I am tring to build a query that returns a char (10) with some data > attatched to the end. > > SELECT (name_first || ',' || name_last) || '1' > > name_first name_last > --------------- ----------------- > ROBERT SMITH > BOB HURT > JIMMY SMITHSON > JO JO > > My result set should be: > ROBERT,SM1 > BOB,HURT 1 > JIMMY,SMI1 > JO,JO 1 > > I tried to assign it to an alias and then use TEMP[1,9] || '1' but it > would not allow my to treat the alias as a regular string. > > Does anyone have any ideas? You don't give much detail, but if you are using UNIX, you could try something like: OUTPUT TO PIPE 'sed -e "s,\\(.........\\).*,\\11,"' WITHOUT HEADINGS SELECT (TRIM(fname) || "," || TRIM(lname)) FROM customer I tested this on the stores7 database, but you get the idea. Might be a good idea to cut and paste rather than trying to count dots and slashes. :-) Hope that helps, -- Mark. +----------------------------------------------------------+-----------+ |Mark D. Stock - Informix SA http://www.informix.com |//////// /| |mailto:mdstock@informix.com http://www.iiug.org |///// / //| | +-----------------------------------+//// / ///| | Tel: +27 11 807 0313 |If it's slow, the users complain. |/// / ////| | Fax: +27 11 807 2594 |If it's fast, the users keep quiet.|// / /////| |Cell: +27 83 250 2325 |Therefore, "No news: travels fast"!|/ ////////| +----------------------+-----------------------------------+-----------+