Re: non-tab delimited output? Logos wrote:
>>select '~'||trim(A)||'~'||trim(B)||'~' as a from a;
>>+-------+
>>| A |
>>+-------+
>>| ~A~B~ |
>>+-------+
>
>
> Thank you...but it didn't work for me. It output a column of 1's. I'm
> actually not sure what the pipes and tildes are supposed to doing
> there, so perhaps I'm not adjusting for something I should be.
>
the || (double pipe) is ansi-standard to "concat" strings together. The ~
(tilde) is merely a field seperator. If omitted, then you must make sure you
data fields are well defined and ALWAYS the same length. Otherwise, when you
import it into something else, how do you where to break it?
eg. col-a int, col-b int
col-a col-b
123 45678
1234 5678
in this example, there is no way to know how many "characters" are in col-a or col-b
Using a mysql-specific function to replace the ansi-standard, you can use:
select concat('~',trim(A),'~',trim(b),'~') as a from a;
note, if the columns are integers, you can remove the trim() function - this is
used to ensure no leading/trailing spaces.
I try to use ansi-standard syntax as it can be translated from one database
engine to another fairly easy. If you use database specific functions - when
you do need to move - you must recode everything because you were not ansi-standard.
--
Michael Austin.
DBA Consultant |