If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Displaying column values in a row

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-08-09, 06:48
sushma007 sushma007 is offline
Registered User
 
Join Date: Aug 2007
Posts: 64
Thumbs down Displaying column values in a row

Hi Friends ,

I have a requirement to display all values of a particular column in a row(like column names) .

i.e

i j k-------------columns
-- -- --
1 'a' 'aa'
2 'b' 'bbb'
3 'c' 'ccc'

now i need a query that shows the below out put..i.e displaying all the values of the column j horizantaly (in a row)

'a' 'b' 'c'

Thanks ,
Sush
Reply With Quote
  #2 (permalink)  
Old 01-08-09, 07:32
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Quote:
Originally Posted by sushma007
Hi Friends ,

I have a requirement to display all values of a particular column in a row(like column names) ...
I looked at your other posts to see what type of server you were using but was surprised to see you are posting queries on Oracle, MySQL, Postgre SQL, SQL Server, MySQL and DB2! What do you use in real life? why are you posting questions on so many different server types? Would it be worth getting a bit more experience with SQL before moving so rapidly between server types? Do you realise you've missed out posting queries on the Sybase forum?

Mike
Reply With Quote
  #3 (permalink)  
Old 01-08-09, 09:26
galih galih is offline
Registered User
 
Join Date: Feb 2008
Location: Bandung - Indonesia
Posts: 15
SELECT j FROM your table name
__________________
Forum Informatika - Indonesian Informatics Online Community - http://if.web.id
Reply With Quote
  #4 (permalink)  
Old 01-08-09, 10:08
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by galih
SELECT j FROM your table name
bzzzt, wrong -- this produces values vertically

your solution is horizontally challenged

sush, look up GROUP_CONCAT in da manual, it will likely do what you need

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 01-08-09, 11:13
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
but Rudy that will only work on MySQL! what about all the other servers sush is working with such as Oracle, Postgre SQL, SQL Server and DB2 - is there no solution to all his problems?
Reply With Quote
  #6 (permalink)  
Old 01-08-09, 11:14
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
no idea, mike, i was just answering the question that was asked in the forum that it was asked in

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 01-08-09, 11:16
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Quote:
Originally Posted by mike_bike_kite
is there no solution to all his problems?
...money?
__________________
George
Twitter | Blog
Reply With Quote
  #8 (permalink)  
Old 01-08-09, 12:17
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
Quote:
Originally Posted by georgev
...money?
no solution to his problems...
try alcohol.....

as Rab C Nesbit will testify alcohol helps the world pass by
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #9 (permalink)  
Old 01-08-09, 12:33
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Quote:
Originally Posted by r937
no idea, mike, i was just answering the question that was asked in the forum that it was asked in

Ahhh yes, that does give the game away a little bit. I'd so much fun following all his other posts in all the other forums that I just assumed (wrongly) he'd posted under database design
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On