谢谢大家.还是有点不明白,请赐教 --如果不使用 GROUP BY 子句,HAVING 的行为与 WHERE 子句一样。 create table t ( id int ) insert into t select 1 insert into t select 2 insert into t select 3 insert into t select 4 insert into t select 5 insert into t select 6 select * from t --要查询id大于3的记录 select * from t where id>3 --要使用having来代替where,难道是这样,好象不对 select * from t having id>3 drop table t
指定组或聚合的搜索条件。HAVING 只能与 SELECT 语句一起使用。通常在 GROUP BY 子句中使用它。如果不使用 GROUP BY 子句,HAVING 的行为与 WHERE 子句一样。
指定群組或彙總的搜尋條件。HAVING 只能與 SELECT 陳述式一起使用。通常在 GROUP BY 子句中使用。不使用 GROUP BY 時,HAVING 則與 WHERE 子句功能相似。
指定组或聚合的搜索条件。HAVING 通常与 GROUP BY 子句一起使用。如果不使用 GROUP BY 子句,HAVING 的行为与 WHERE 子句一样。
.........................
它是对group语句的进一步筛选.
可以举个例子不.....
错
select count(*) from 表1 having count(*)>1 没错~~~只是没什么意义~~
libin_ftsafe(子陌红尘:当libin告别ftsafe)可以举个有意义点的例不吗
最进常常打错字~~让观众受伤了
--如果不使用 GROUP BY 子句,HAVING 的行为与 WHERE 子句一样。
create table t
(
id int
)
insert into t select 1
insert into t select 2
insert into t select 3
insert into t select 4
insert into t select 5
insert into t select 6
select * from t
--要查询id大于3的记录
select * from t where id>3
--要使用having来代替where,难道是这样,好象不对
select * from t having id>3
drop table t
須與group by 同時使用才有意義