select id ,email from user where email in
(select b.email from user where trim(ifnull(b.email,'')) <>''group by b.email having count(*)>=2)
order by email-这样的语句是很多 的 。 有时候他跑几个小时不出数据。这种表达方式显然是错误的。 问错误原因
(
修改可以下面的方式:
select id ,email from user inner join (select email from user where trim(ifnull(b.email,'')) <>''group by b.email having count(*)>=2) b
on a.email=b.email
order by email
这个是可以的
)需要知道错误原因? (mysql不支持这种表达?)
(select b.email from user where trim(ifnull(b.email,'')) <>''group by b.email having count(*)>=2)
order by email-这样的语句是很多 的 。 有时候他跑几个小时不出数据。这种表达方式显然是错误的。 问错误原因
(
修改可以下面的方式:
select id ,email from user inner join (select email from user where trim(ifnull(b.email,'')) <>''group by b.email having count(*)>=2) b
on a.email=b.email
order by email
这个是可以的
)需要知道错误原因? (mysql不支持这种表达?)
解决方案 »
- 菜鸟求助,MYSQL不同进入方式显示的用户不一样
- mysql语句select id from user where info like '%'+id,like后的怎么写?
- 【求助】myisam类型的数据库如何添加数据表
- PostgreSQL数据库 数据恢复的问题 急啊!! 在线等!!!!拜托
- Mysql超复杂查询,考验你的能力,大虾们帮帮忙啦··
- OTL通过MyODBC连接mysql需要用什么库
- 求教!mysql千万级数据多表查询做分页该如何优化?
- MySQL学习无需等待,你的学习你做主!
- 如何根据需求搭建一个优质合格的数据库
- mysql8.0的客户端连接到mysql5.6的服务器报1045权限错误
- 急 在线等 多麻烦各位大侠了
- 关于MYSQL的innodb表备份的问题
select id from rt t
where exists (select 1 from rt m where m.a=t.a
and m.b=t.b
and m.c=t.c
where exists (select 1 from rt m where m.a=t.a
and m.b=t.b
and m.c=t.c 这个时间太长 不知道等到什么时间去了
where exists (select 1 from rt m where m.a=t.a
and m.b=t.b
and m.c=t.c不能出现数据 (昨天一个大表是可以出数据 这种写法 )
select id ,email
from user
where email in (
select b.email
from user
where trim(ifnull(b.email,'')) <>''
group by b.email
having count(*)>=2
)
order by email
-- 2 ---
select id ,email
from user inner join (
select email
from user
where trim(ifnull(b.email,'')) <>'' -- 在B未定义前就引用,语法有问题。
group by b.email
having count(*)>=2) b
on a.email=b.email
order by email-- 3 ---
select id ,email
from user a
where exists (
select 1 from user
where email=a.email and id != a.id
)
from user
where email in (
select email
from user
where trim(ifnull(email,'')) <>''
group by email
having count(*)>=2
)
order by email -----确实前面多加了好多的 d. 这个问题说明了mysql 的子查询有很大的问题
------只能用inner join来解决