List:General Discussion« Previous MessageNext Message »
From:Thimble Smith Date:August 5 1999 12:31am
Subject:Re: Concat'ing columns
View as plain text  
CREATE TABLE tmp_names (name CHAR(100));

INSERT INTO tmp_names (name) SELECT columnA FROM some_table;
INSERT INTO tmp_names (name) SELECT columnB FROM some_table;

SELECT name FROM tmp_names GROUP BY name;

DROP TABLE tmp_names;

I question your database design, though, if it requires this
operation.

Tim


At 19:24, 19990804, jordanh@stripped wrote:
>
>
>	Perhaps you should read the fine question, or perhaps I wasn't
>clear enough:  I would like to like two columns, and add them together
>serially.
>
>
>[------------------]		[------------------]
>|    ColumnA       |		|    ColumnB       |
>|------------------|		|------------------|
>|   Steve Ruby     |		|   Jordan Husney  |
>|   Linus Torvalds |		|   Alan Cox       |
>|   Ghandi         |		|   Snoopy         |
>|   Linus Torvalds |		|   Linus Torvalds |
>|   Jordan Husney  |		|   Steve Ruby     |
>[------------------]		[------------------]
>
>
>Thus ColumnA and ColumnB would produce:
>
>[-------------------]
>| ColumnA & ColumnB |
>|-------------------|
>| Steve Ruby        |
>| Jordan Husney     |
>| Linus Torvalds    |
>| Alan Cox          |
>| Ghandi            |
>| Linus Torvalds    |
>| Linus Torvalds    |
>| Jordan Husney     |
>| Steve Ruby        |
>[-------------------]
>
>
>And the distinct set would be:
>
>[---------------------] 
>| Distinct Set of A&B |
>|---------------------|
>| Steve Ruby          |
>| Jordan Husney       |
>| Linus Torvalds      |
>| Alan Cox            |
>| Ghandi              |
>| Snoopy              |
>[---------------------]
>
>
>	Is there a way to _add_ (sorry if concat was a poor choice of
>words) two columns together and grab only the distinct set that this
>addition provides?
>
>
>Jordan.
>
>
>Ahh the fine illistrative properties of ASCII diagrams!
>
>
>On Wed, 4 Aug 1999, Steve Ruby wrote:
>
>> 
>> concat(name1,name2)
>> 
>> you should probably read the manual, see under String Functions
>> 
>> On Wed, 4 Aug 1999 jordanh@stripped wrote:
>> 
>> > 
>> > 	Is it possible to concatonate to columns together?  The
>> > application is as follows: take two columns full of names, find all the
>> > distinct names by concatonating this columns.
>> > 
>> > Psudo-SQL (?):
>> > 
>> > SELECT DISTINCT (CONCAT Names1,Names2) FROM table1;
>> > 
>> > 
>> > Thank you,
>> > 
>> > 
>> > Jordan Husney.
>> > 
>> > 
>> > 
>> > ---------------------------------------------------------------------
>> > Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
>> > posting. To request this thread, e-mail mysql-thread9397@stripped
>> > 
>> > To unsubscribe, send a message to the address shown in the
>> > List-Unsubscribe header of this message. If you cannot see it,
>> > e-mail mysql-unsubscribe@stripped instead.
>> > 
>> > 
>> 
>
>
>---------------------------------------------------------------------
>Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
>posting. To request this thread, e-mail mysql-thread9418@stripped
>
>To unsubscribe, send a message to the address shown in the
>List-Unsubscribe header of this message. If you cannot see it,
>e-mail mysql-unsubscribe@stripped instead.
>
Thread
Concat'ing columnsjordanh5 Aug
  • Re: Concat'ing columnsSteve Ruby5 Aug
    • Re: Concat'ing columnsjordanh5 Aug
      • Re: Concat'ing columnsThimble Smith5 Aug
        • Re: Concat'ing columnsjordanh5 Aug
          • Re: Concat'ing columnsThimble Smith5 Aug