w******n 发帖数: 15 | 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? | s********e 发帖数: 62 | 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
| a***s 发帖数: 1084 | 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
|
|