另外这个只是返回前3个,但是如果我希望相同数字的话只算一个呢?比如: word count A 12 B 4 C 15 D 15 E 15 … … X 20我希望返回E,C,D,E,A
select * from table1 a where 3>(Select count(*) From table1 where word.a.word and `count`>a.`count`);
这句话的语法是不是有问题???没看到table1后面的 a 是什么意思?还有word.a.word 理解不了。
也许是我举得这个例子的属性名不太好。改一下吧。还是叫table1 word w_count a 10 b 13 c 10 d 5 e 2 f 10
mysql> select * from TE a where 3>(Select count(*) From TE where word.a.word and `count`>a.`count`); ERROR 1054 (42S22): Unknown column 'word.a.word' in 'where clause' TE是这个表的表名,数据和我上一回帖贴出来的一样
忘了说,第二贴的列名还是之前的count
select * from TE a where 3>(Select count(*) From TE where word=a.word and `count`>a.`count`);
谢谢,可以实现。顺便问问这个到底是什么语法??我没见过。where 前面的a是起到什么作用?
A是TE表别名 select a.word,count(*) from TE a left join te b on b.word=a.word and b.`count`>a.`count` group by a.word 看看结果就知道了
不好意思....后来我查了一下,好像结果不对呀!!! word count a 10 b 13 c 10 d 9 e 2 f 10 g 9其结果和原表一样...
'截至2011-09-01 07:38:13 用户结帖率0.00% 当您的问题得到解答后请及时结贴.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html8、如何给分和结贴?
http://community.csdn.net/Help/HelpCenter.htm#结帖
word count
A 12
B 4
C 15
D 15
E 15
… …
X 20我希望返回E,C,D,E,A
select * from table1 a where 3>(Select count(*) From table1 where word.a.word and `count`>a.`count`);
这句话的语法是不是有问题???没看到table1后面的 a 是什么意思?还有word.a.word 理解不了。
word w_count
a 10
b 13
c 10
d 5
e 2
f 10
mysql> select * from TE a where 3>(Select count(*) From TE where word.a.word and
`count`>a.`count`);
ERROR 1054 (42S22): Unknown column 'word.a.word' in 'where clause'
TE是这个表的表名,数据和我上一回帖贴出来的一样
`count`>a.`count`);
谢谢,可以实现。顺便问问这个到底是什么语法??我没见过。where 前面的a是起到什么作用?
select a.word,count(*) from TE a left join te b on b.word=a.word and b.`count`>a.`count`
group by a.word
看看结果就知道了
word count
a 10
b 13
c 10
d 9
e 2
f 10
g 9其结果和原表一样...