【发布时间】:2014-07-02 05:57:42
【问题描述】:
情况: 我有一个场景,我得到的数据除了一个字段外,所有字段都相同。我编写了一个存储过程来获取数据,使用来自不同表的许多连接。就我而言,我需要这两种情况中的任何一种,具体取决于情况。 例如:
实际案例
|UserId | First name | Last name | IsRequired | IsDeleted |
1 harry tom true false
1 harry tom false false
3 ram sham true false
场景:
如果有两条 IsRequired 分别为 true 和 false 的记录,那么我需要一个 IsRequired 为 true 的案例。
问题:
现在的问题是我需要过滤掉 select 语句中的记录。
所以任何人都知道如何在 select 语句中执行此操作。
预期情况:
| UserId | First name | Last name | IsRequired | IsDeleted |
1 harry tom true false
2 ram sham true false
【问题讨论】:
-
在选择查询中尝试 Distinct
-
您需要 MySQL、SQL Server 或两者的解决方案吗?
-
select * from table where IsRequired='true'? -
我不能使用 select * from table where IsRequired='true' 因为它会过滤 Isrequired true 的其他记录。
标签: mysql sql sql-server