简体   繁体   English

SQL:从表中选择行,其中列的每个元素都是矩阵?

[英]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.

相关问题 python,如何从矩阵的每一列中选择元素 - python, how to select element from each column of matrix 如果 B[i, j] == 1,则从 A 创建包含每列 A 行平均值的新矩阵,其中 B 是邻接矩阵 - Creation of new matrix from A containing the average value of A rows for each column if B[i, j] == 1 where B is an adjacency matrix 如果 B[i, j] == 1 其中 B 是邻接矩阵,则从 A 生成包含每列 A 行平均值的新矩阵 - Generate new matrix from A containing the average value of A rows for each column if B[i, j] == 1 where B is an adjacency matrix Select Numpy 数组中的所有行,其中每列满足某些条件 - Select all rows from Numpy array where each column satisfies some condition 如何从表中找到每列总和特定数字(或范围)的行组合? - How can I find a combination of rows from a table where each column sums a specific number (or range)? 选择列与列表SQLAlchemy的元素匹配的行 - Select rows where a column matches an element of a list SQLAlchemy 如何将 numpy 向量转换为矩阵,其中矩阵中的每一列都包含初始向量中各个元素周围的范围? - How to turn a numpy vector into a matrix, where each column in the matrix contains a range around the respective element in the initial vector? 在 Sql Alchemy 中,如何在 select 行中的任何列包含 substring? - In Sql Alchemy, how to select rows where any column contains a substring? 创建一个矩阵,其中每个元素等于其行和列索引的最小值 - Creating a matrix where each element is equal to the minimum of its row and column index python sql,“选择? 从表在哪里? 像?”,(选择,在哪里,像) - python sql, “select ? from table where ? like ?”,(selected,where,like))
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM