Actually this is not easy task, you want to loop it by finding the below query.
SELECT table_name, column_name
FROM all_tab_columns
--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 '%%'
breemstone
Member
8 Points
27 Posts
SQL QUERY
Aug 28, 2012 08:44 AM|LINK
Hi,
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?
Please help
SohailShaikh
Contributor
6281 Points
1188 Posts
Re: SQL QUERY
Aug 28, 2012 08:56 AM|LINK
select * from mytable where column1='x or any value' will be show
Sohail Shaikh
breemstone
Member
8 Points
27 Posts
Re: SQL QUERY
Aug 28, 2012 09:05 AM|LINK
I'd like to display the columns where the record value='x' ,not where 'column1=x'
Ajay2707
Contributor
5068 Points
973 Posts
Re: SQL QUERY
Aug 28, 2012 01:20 PM|LINK
Hi Breemstone,
Actually this is not easy task, you want to loop it by finding the below query.
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?