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
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