RE: [PHP] Combining Columns in MySQL for PHP
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:[EMAIL PROTECTED]] > Sent: Saturday, July 27, 2002 4:08 PM > To: [EMAIL PROTECTED] > 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" <[EMAIL PROTECTED]> wrote in message > 000201c235a7$59348560$b402a8c0@mango">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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
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" <[EMAIL PROTECTED]> wrote in message 000201c235a7$59348560$b402a8c0@mango">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
RE: [PHP] Combining Columns in MySQL for PHP
> 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
[PHP] Combining Columns in MySQL for PHP
I was wondering if there was any way to get MySQL to combine the specified SELECT columns into one column. i.e., 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". Is there any thing that does this in MySQL, or do I have to do this in PHP? I've been searching mysql.com, but there search engine seems to be broken and gives me errors frequently. :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php