select * from tb6 where id=(select count(*) from tb6)
select * from t where cnt=(SELECT COUNT(*) FROM [TABLE]) 猜一个 请贴出“别的SQL”
用having COUNT(*) 不行吗?
。意思可能没说清楚,SELECT COUNT(*) FROM TABLE得到的记录数为1时作为查询条件,且嵌套的表中没有可匹配的字段
It is still beyond my understanding...if (SELECT COUNT(*) FROM TABLE)=1 --do sth. else --do sth. else
知道你啥意思了 declare @a varchar(20), --看你要什么类型的 @sql varchar(8000) --用来记录SQL语句 begin set @a=SELECT COUNT(*) FROM TABLE set @sql='select * from table where a='+@a exec(@sql) end这样就把条件带进去了 我经常这么干
select * from tb6 where id=(select count(*) from tb6)
select * from tb where id=case when (select count(*) from tb)=1 then (select count(*) from tb) end
。意思可能没说清楚,SELECT COUNT(*) FROM TABLE得到的记录数为1时作为查询条件,且嵌套的表中没有可匹配的字段是否如下面 表 字段f1 aaa aaa bbb ccc ddd ccc 查无重复的记录 select * from 表 as a where (select count(*) from 表 where f1=a.f1)=1
*
from t
where cnt=(SELECT COUNT(*) FROM [TABLE])
猜一个
请贴出“别的SQL”
--do sth.
else
--do sth. else
declare
@a varchar(20), --看你要什么类型的
@sql varchar(8000) --用来记录SQL语句
begin
set @a=SELECT COUNT(*) FROM TABLE
set @sql='select * from table where a='+@a
exec(@sql)
end这样就把条件带进去了
我经常这么干
表
字段f1
aaa
aaa
bbb
ccc
ddd
ccc
查无重复的记录
select * from 表 as a where (select count(*) from 表 where f1=a.f1)=1