[英]SQL: select rows from table where each element of a column is a matrix?
I have a huge table with several columns. 我的桌子很大,有几列。 Each element in column_H is a little matrix 2x4, with booleans.
column_H中的每个元素都是一个2x4的小矩阵,带有布尔值。
I need to SELECT the rows WHERE the 8 boolean elements in column_H, per row, are False. 我需要选择column_H中每行8个布尔元素为False的行。
Is it possible? 可能吗? How?
怎么样? (I am employing a Python wrapper to SQL)
(我正在将Python包装器用于SQL)
Well, if your database supports booleans, then you would just do: 好吧,如果您的数据库支持布尔值,那么您只需执行以下操作:
select t.*
from t
where not bool1 and not bool2 and not bool3 and not bool4 and
not bool5 and not bool6 and not bool7 and not bool8;
If your values are bit-encoded, then they are not "boolean"s. 如果您的值是位编码的,则它们不是“布尔值”。 It might work to compare:
比较一下可能会起作用:
where column_h = 0
Each element in col_H is a matrix, so I don't have direct access to each boolean but only to the matrix. col_H中的每个元素都是一个矩阵,因此我无法直接访问每个布尔值,而只能直接访问该矩阵。
Since I am employing a Python wrapper to SQL, I just figured I could try to mix both languages :-S 由于我将Python包装器用于SQL,因此我只是想可以混合使用两种语言:-S
And now I managed to make it work! 现在我设法使它起作用了! My actual code is:
我的实际代码是:
select *
from table
where col_H[0,0] == False
&& col_H[0,1] == False
&& col_H[1,0] == False
&& col_H[1,1] == False
&& col_H[2,0] == False
&& col_H[2,1] == False
&& col_H[3,0] == False
&& col_H[3,1] == False
;
It works perfectly. 它运作完美。
Thanks! 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.