Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 28, 2012 01:20 PM by Ajay2707
Aug 28, 2012 08:44 AM|LINK
Is there a way I can display column names from a table where 'column' = 'value'
E.g I have a table with column names 'column1','column2','column3' .
I then insert a record : insert into mytable (column1,column2,column3) values ('x','x','y')
How can I display the record in such a way that only columns with value 'x' are shown?
Aug 28, 2012 08:56 AM|LINK
select * from mytable where column1='x or any value' will be show
Aug 28, 2012 09:05 AM|LINK
I'd like to display the columns where the record value='x' ,not where 'column1=x'
Aug 28, 2012 01:20 PM|LINK
Actually this is not easy task, you want to loop it by finding the below query.
SELECT table_name, column_name
--WHERE column_name LIKE '%%'
WHERE table_name LIKE '%%'
Make cursor with above query , this will get no. of column in your table. after that in each loop you make string to pass column name with where clause (as you make in simple query with column to find 'x' value). there you set count . So in every loop you get that col does have 'x' value or not
But, Why you want to do this?
SELECT table_name, column_name FROM all_tab_columns --WHERE column_name LIKE '%%' --WHERE table_name LIKE '%%'