我正在使用 MySQL 中的一个表,其中包含以下列:
id, january, february, march, april, etc
表中的数据如下所示:
aa, 0, 0, 1, 0
ab, 1, 0, 1, 0
ac, 1, 1, 0, 0
ad, 1, 1, 1, 0
要查询它,我可以轻松地执行以下操作:
select * from table where january = 1 and february = 1
结果将是:
ac, 1, 1, 0, 0
ad, 1, 1, 1, 0
我想知道是否有办法做到这一点:
select * from table where table.columns = 1
我想在表达式中使用表列,而无需实际手动指定名称(将其键入)。
奖励 (+1) 问题:
是否可以使用 Match/Against 来完成,如下所示:
select * from table
where
(
match (somehow,get,the,table,columns,I,need,here)
against (1 in boolean mode)
)
谢谢你的时间! :)