2 回答

TA貢獻1880條經驗 獲得超4個贊
空白是可以的,因為您試圖獲取字段鍵 = 結束日期和字段鍵 = 合同狀態的所有記錄,這是不可能的。
您可以嘗試使用 OR 代替 AND。
喜歡
select pfv.*
from ProjectFieldValue pfv
where (pfv.dateValue between '2019-05-01' AND '2019-05-30' AND pfv.fieldKey = 'closing_date')
OR(pfv.textValue = 'Open' AND pfv.fieldKey = 'contract_status')
此外,我更改了 pfv.textValue = 'Close' 為 pfv.textValue='Open' 因為““contact_status”的 fieldKey 和“Open”的 fieldKey 的 textValue”
然后你會得到滿足的記錄
“contact_status”的 fieldKey 和“Open”的 fieldKey 的 textValue 或
“close_date”的fieldKey和2019-05-01 AND 2019-05-30之間的dateValue
如果只想獲取 1.“contact_status”的 fieldKey 和“Open”的 fieldKey 的 textValue
你可以
select pfv.*
from ProjectFieldValue pfv
where pfv.textValue = 'Open' AND pfv.fieldKey = 'contract_status'
并只獲取記錄
“close_date”的fieldKey和2019-05-01 AND 2019-05-30之間的dateValue
select pfv.*
from ProjectFieldValue pfv
where (pfv.dateValue between '2019-05-01' AND '2019-05-30' AND pfv.fieldKey = 'closing_date')

TA貢獻1804條經驗 獲得超2個贊
- 2 回答
- 0 關注
- 149 瀏覽
添加回答
舉報