这是我的表格数据。
column_1_____column_3_____column_4_____column_5_____column_6_____column_7_____column_8
yes no yes yes yes no yes
这里,它们只是一个数据行
我只想要具有value = 'yes'
的列。
为此查询有效吗?
SQL不是围绕列组织的。它围绕行组织。您可以使用以下查询来执行所需的操作:
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';
您的想法不适合sql逻辑。因为您想了解一些信息,所以查询尚未生效。