This is my table data..
column_1_____column_3_____column_4_____column_5_____column_6_____column_7_____column_8
yes no yes yes yes no yes
here, their is only one datarow
i want only that columns which has value = 'yes'
.
for this which query works?
Thanks.
SQL is not organized around columns. It is organized around rows. You can do what you want with a query like this:
select 'column1' as col
from t
where column1 = 'yes'
union all
select 'column2' as col
from t
where column2 = 'yes'
union all
. . .
union all
select 'column8' as col
from t
where column8 = 'yes';
Your idea isn't suitable for sql logic. Because you want to know something, before query hasn't work yet.