Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 18th, 2011, 08:01 AM
Authorized User
Join Date: Aug 2011
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Red face Query for Cloumn field as Rows


I want to display column values as rows... Can anyone give me sql query for this...

My table looks like this - :
SELECT pk_userId, user_name
FROM dbo.User_Table

2 emma
3 manoj
4 sneha
5 Ankita
6 enna

Now I want a query for this -

emma| manoj| sneha| Ankita| enna ==> thiese are column name
| | | |
Reply With Quote
  #2 (permalink)  
Old August 19th, 2011, 09:26 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

There really isn't any standard SQL to do this because it doesn't fit the set model of SQL tables.

This sounds to me like you have a problem with the way you are constructing your table. Why do you have columns for the users? You should have a table with columns like UserID & UserName, then a row for each user. Then getting the list of users becomes trivial:
SELECT * FROM user_table
Reply With Quote

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 Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Query on million of rows wkm1925 SQL Server 2000 6 October 23rd, 2006 09:30 AM
How to check whether query retuns some rows or not kumar_raj13 ASP.NET 1.0 and 1.1 Professional 1 March 13th, 2006 12:59 AM
Query That Return 0 Rows in Results nimrod_r BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 June 5th, 2005 02:14 AM
getting a query rows as columns raamts SQL Language 1 February 24th, 2005 04:06 AM
Storing complete table rows in a single field KenNeedham Oracle 2 January 22nd, 2004 01:45 PM

All times are GMT -4. The time now is 05:05 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.