比如:table T1.
id(char) name(char) age(char)
1 n1 18
1 n2 19
1 n2 20
2 n2 18
2 n2 19
3 n3 18
请各位达人帮忙给出“查询出age(char)有多个值的id的记录”的语法,谢谢。
您的语句查出的是,每个age(char)分别出现多少次。与我的问题不符。
谢谢。
select * from Tab as a where exists(select 1 from Tab where ID=a.ID and Agea.Age)
这条专家回答给的语句,查询出是age出现大于一次的记录。继续追问一下,我想查,age出现具体次数的记录,比如出现三次的记录,或者4次的记录,该怎么查呀?
select * from Tab as a where (select count(distinct Age) from Tab where ID=a.ID ) =3
--可以這樣寫,查出記錄3 這里自己加條件 如:>1