我有一张这样的表:
Timer timer = new Timer();
TimerTask doAsynchronousTask = new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
public void run() {
ScrollView sv =(ScrollView)findViewById(R.id.scrl);
sv.scrollTo(0, 10);
}
});
}
};
timer.schedule(doAsynchronousTask, 0, 100000);
现在我要选择第一行和第四行。因为它们具有相同的// mytable
+----+--------------------------+---------------+-----------------+
| id | Email | IP | cookies |
+----+--------------------------+---------------+-----------------+
| 1 | jack.123@gmail.com | 172.95.65.7 | 5c6ffbdd40d95 |
| 2 | ali.mngvv@yahoo.com | 84.15.2.4 | 26b73a21e63c3 |
| 3 | redhat1931@gmail.com | 124.54.32.1 | e0e904b73a2fe |
| 4 | peter_1998@gmail.com | 172.95.65.7 | 5c6ffbdd40d95 |
| 5 | b.batman@ymail.com | 56.23.41.3 | b23a51a63edf4 |
| 6 | ali.mngvv@yahoo.com | 84.15.2.4 | 26b73a21e63c3 |
+----+--------------------------+---------------+-----------------+
,相同的IP
和不同的Cookies
。我怎样才能选择它们?
我想要输出
Email
答案 0 :(得分:1)
您可以将exists
用作
select m1.* from mytable m1
where exists (
select 1 from mytable m2
where
m1.Email <> m2.Email
and m1.IP = m2.IP
and m1.cookies = m2.cookies
)
答案 1 :(得分:0)
试试这个,它会帮助你
SELECT id, Email,IP, cookies, COUNT(*) FROM mytable GROUP BY IP, cookies HAVING COUNT(*) > 1
答案 2 :(得分:0)
这里的解决方案没有使用子查询,基本上是另一种查询方式。
SELECT m1.*
FROM mytable m1,mytable m2
WHERE (m1.`Email`<> m2.`Email`) AND (m1.`IP`=m2.`IP`) AND (m1.`cookies`=m2.`cookies`);