Is it possible to retrieve specific columns of specific rows in an SQL query?
Let\'s say I\'m selecting from my SQL table, called my_
2 imp points
1. 1000 columns in single table is against RDBMS and its highly unnormalised table.
2. rows doesnot have name.
Now if you know names of columns then use following:
"select column_1,column_2 from my_table where primary_key_column in ('1','2');"
here column_1,column_2 are names of columns you want.
primary_key_column to uniquely define your rows and in brackets all the primary keys you need to retrieve.
If you know only know column numbers then use following to retrieve column names:
"SELECT Column_name FROM user_tab_columns where table_name = 'MY_TABLE' and Column_id in (1,2,5);"
Hope this will help.
For further reference http://www.w3schools.com/sql/