Redian新闻
>
a simpler sQL question, high help please!!!!
avatar
a simpler sQL question, high help please!!!!# Database - 数据库
w*n
1
ok, a more simpler question:
say i have a table like this
ID LOGID
1 2
1 3
1 4
2 2
2 3
say i have another table that has
ID
1
2
3
4
.
.
how do i count each ID different? means i want to find out
how many LOGID each id has?
avatar
s*e
2
select ID, count(*)
from ....

【在 w******n 的大作中提到】
: ok, a more simpler question:
: say i have a table like this
: ID LOGID
: 1 2
: 1 3
: 1 4
: 2 2
: 2 3
: say i have another table that has
: ID

avatar
a*s
3
hope this works :
CREATE TEMPORARY TABLE tmp (
customerID INT(10) UNSIGNED DEFAULT '1' NOT NULL auto_increment,
statID INT(10) unsigned default '0' NOT NULL,
);
LOCK TABLES log read;
INSERT INTO tmp select customerID , count(*) from log where typeID = 1
group by customerID ;
SELECT custormerID FROM tmp
WHERE statID > 1 ;
UNLOCK TABLES;
DROP TABLE tmp;

【在 w******n 的大作中提到】
: ok, a more simpler question:
: say i have a table like this
: ID LOGID
: 1 2
: 1 3
: 1 4
: 2 2
: 2 3
: say i have another table that has
: ID

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。