首先,我很抱歉,如果之前已经提出这个问题,我真的很想搜索,但无法找到我想要的东西。
好的,这是我的桌子。我想要一个查询,我选择具有相同精确值超过2次的用户ID。
| USER ID|COLOR|
---------|-------
| 1 | BLUE
| 2 | BLUE
| 3 | RED
| 4 | BLUE
所以我的查询会返回
| USER ID|
|--------|
| 1 |
| 2 |
| 4 |
非常感谢!
答案 0 :(得分:2)
您似乎想要选择select userid
from yourtable t
where exists (
select 1
from yourtable t2
where t.userid <> t2.userid and t.color = t2.color
)
重复两次以上的行。这是一种方法:
color
您要求超过2次匹配。对于2场或更多场比赛,您将使用sgeddes的解决方案:
select t.*
from t join
(select color, count(*) as cnt
from t
group by color
) tt
on tt.color = t.color and cnt > 2;
或者,如果您只想要多个ID:
select t.*
from t
where exists (select 1
from t tt
where t.color = tt.color and t.userid <> tt.userid
);
答案 1 :(得分:1)
以下是使用<div>
<div id="HoverMe" style="width: 100px; background: green">
Car
</div>
<div id="hidden" style="overflow:auto; height:100px; position: absolute; background-color: red; display: none">
@foreach (var car in Model.Car) { @* Where the #hidden list get its content *@
<div>@car.Name</div>
}
</div>
</div>
<script>
var hoverEle = document.getElementById("HoverMe");
var popupEle = document.getElementById("hidden");
var timeoutId;
function showPopup() {
var hoverRect = hoverEle.getBoundingClientRect(); // get the position of the hover element
popupEle.style.left = (hoverRect.right + 16) + "px";
popupEle.style.top = hoverRect.top + "px";
popupEle.style.display = "block";
}
function hidePopup() {
popupEle.style.display = "none";
}
hoverEle.addEventListener('mouseover', function () {
showPopup();
}, false);
hoverEle.addEventListener('mouseout', function () {
timeoutId = window.setTimeout(function () {
hidePopup();
}, 5000);
}, false);
popupEle.addEventListener('mouseover', function () {
if (timeoutId) {
window.clearTimeout(timeoutId);
}
}, false);
popEle.addEventListener('mouseout', function () {
hidePopup();
}, false);
</script>
的一个选项:
exists