php - PHP MySQL仅显示表中具有多条记录的唯一值
问题描述
我很难过,我不知道如何使用多个不同的标识符在表格上获取结果,然后对结果进行分组
简而言之,这是我的表ProjectFieldValue
id | project_id | textValue | dateValue | fieldKey
================================================================
1 | 1000 | Closed | NULL | contract_status
================================================================
2 | 1000 | NULL | 2019-05-01 | closing_date
================================================================
3 | 1001 | Open | NULL | contract_status
================================================================
4 | 1001 | NULL | 2019-05-22 | closing_date
================================================================
5 | 1002 | Closed | NULL | contract_status
================================================================
6 | 1002 | NULL | 2019-05-11 | closing_date
================================================================
7 | 1003 | Closed | NULL | contract_status
================================================================
8 | 1003 | NULL | 2019-05-24 | closing_date
================================================================
我需要运行查询以获取所有记录...
“contact_status”的fieldKey和“Open”的那个fieldKey的textValue
“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')
AND (pfv.textValue = 'Closed' AND pfv.fieldKey = 'contract_status')
谢谢
解决方案
我认为您需要将您的选择拆分为 2 并进行子查询....查看此文档:
推荐阅读
- c++ - C++ Builder 允许与 Int 进行字符串比较 - 为什么?
- c++ - 在 C++ 中计算一次后跨多个线程共享只读数据
- r - 根据上一列添加 NA
- performance - jQuery延迟加载图像和带有后备的webp
- azure-storage - Azure datafactory v2 Linkedservice 构建
- java - 使用假 S3Event 测试我的 AWS Lambda 函数
- dart - 转换列表
到地图 > - jquery - 将 JQuery val() 转换为 ASP 表单无法识别“提交”
- powershell - 向 CSV 添加列会在第一条记录周围留下单引号
- postgresql - 数据库 SQL:如何使用 regexp_substr 从序列中提取数据?