我想在同一查询中使用多个条件,然后使用
这类:
SELECT fieldvalue
FROM (
SELECT jsonb_array_elements(fielddata) AS fieldvalue,
process_id as process_id
FROM field
) t
WHERE t.process_id='8fea394a83b70569432382e1dadc629b'
AND (t.fieldvalue->>'name' = '21312ghfhgfhfghgf' AND t.fieldvalue->'value'->>'stringValue' IS NOT NULL)
AND (t.fieldvalue->>'name' = '211115ghfghfhfhff' AND t.fieldvalue->'value'->>'stringValue' IS NULL)
在查询FIELD中是视图,并且在字段名中具有jsonb类型的视图中的FIELDVALUE中,问题在条件分别给出结果的情况下运行
SELECT fieldvalue
FROM (
SELECT jsonb_array_elements(fielddata) AS fieldvalue,
process_id as process_id
FROM field
) t
WHERE t.process_id='8fea394a83b70569432382e1dadc629b'
AND (t.fieldvalue->>'name' = '21312ghfhgfhfghgf' AND t.fieldvalue->'value'->>'stringValue' IS NOT NULL)
但是当运行两个AND时,它给出0行
SELECT fieldvalue
FROM (
SELECT jsonb_array_elements(fielddata) AS fieldvalue,
process_id as process_id
FROM field
) t
WHERE t.process_id='8fea394a83b70569432382e1dadc629b'
AND (t.fieldvalue->>'name' = '21312ghfhgfhfghgf' AND t.fieldvalue->'value'->>'stringValue' IS NOT NULL)
AND (t.fieldvalue->>'name' = '211115ghfghfhfhff' AND t.fieldvalue->'value'->>'stringValue' IS NULL) AND ....;
答案 0 :(得分:0)
您正在基于
查询数据t.fieldvalue->'name'='21312ghfhgfhfghgf'和 t.fieldvalue->'name'='211115ghfghfhfhff'
表达式的计算结果为false,并且不返回任何内容。就像要水果既是香蕉又是芒果一样。
如果要查询将返回与
t.fieldvalue->'name'='21312ghfhgfhfghgf'和 t.fieldvalue->'name'='211115ghfghfhfhff'
然后考虑使用“ OR” 。
所以您可能要查询以下内容:
for section in 0...self.tableView.numberOfSections - 1 {
for row in 0...self.tableView.numberOfRows(inSection: section) - 1 {
let cell = self.tableView.cellForRow(at: NSIndexPath(row: row, section: section) as IndexPath)
print("Section: \(section) Row: \(row)")
}
}