Please let me know if columns can be displayed row-wise instead of column-wise. For example, for the query:

select empno, ename from emp;

empno  ename
1234   Raj
1235   Christy

Can this be printed in the following format:

empno: 1234
ename: Raj
empno: 1235
ename: Christy

    Requires Free Membership to View

Yes, it's possible, but it would be an awful kluge to do it with just SQL.

Some things are better done in the database with SQL. For example, if you want to filter rows from a table, the best way to do this is with the WHERE clause. But some things are better done in the client tier, i.e., the application program or script. For example, to reformat the output from rows into columns as you have suggested, a simple array loop will do it, where the elements of the array are the columns of each row. This is a very simple programming task in any application or scripting language, but a real problem to do effectively with just SQL.

This was first published in January 2006

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: