RE: [PHP] Combining Columns in MySQL for PHP

From: Date: Sat, 27 Jul 2002 20:26:42 +0000
Subject: RE: [PHP] Combining Columns in MySQL for PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-110001@lists.php.net to get a copy of this message
You have a bad database design if you need something like what you are describing. The columns should probably be in another table, with a second column, a number, saying which column the number is for. So your second table would look like the result you want to have... You may be able to do it with a temporary table, though: INSERT INTO temp (col) SELECT col1 FROM your_table; INSERT INTO temp (col) SELECT col2 FROM your_table; SELECT col FROM temp ORDER BY col ASC; ---John Holmes... > -----Original Message----- > From: Chris Earle [mailto:chris@earleweb.com] > Sent: Saturday, July 27, 2002 4:08 PM > To: php-general@lists.php.net > Subject: Re: [PHP] Combining Columns in MySQL for PHP > > Thanks for the reply, and I see that I didn't get specific enough (my > fault! > sorry). > > Here's what I want to take from: > > +-----+------+ > | col_1| col_2 | > +-----+------+ > | 2.0 | 6.8 | > +-----+------+ > | 4.1 | 8.9 | > +-----+------+ > > I want to do something like SELECT COMBINE(col_1, col_2) as col FROM > column_list ORDER BY col; > > Which would give me: > > +---+ > | col | > +---+ > | 2.0 | > +---+ > | 4.1 | > +---+ > | 6.8 | > +---+ > | 8.9 | > +---+ > > CONCAT would only work if I want strings concatenated on the same row. Is > there some way I can use JOIN to get what I want? > > "John Holmes" <holmes072000@charter.net> wrote in message > news:000201c235a7$59348560$b402a8c0@mango... > > > SELECT COMBINE(column_1, column_2) As column FROM column_list; > > > > > > Would give me the results of column_1 and column_2 simply by going > > through > > > "column". > > > > Use CONCAT() where you have COMBINE(). > > > > ---John Holmes... > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#110001) next »