SELECT id FROM tbl GROUP BY id HAVING COUNT(*) = N;
4. 计算两个日子间的工作日 所谓工作日就是除出周六周日和节假日。
SELECT COUNT(*) FROM calendar WHERE d BETWEEN Start AND Stop AND DAYOFWEEK(d) NOT IN(1,7) AND holiday=0; http://www.csvt.net/
5. 查找表中的主键
SELECT k.column_name FROM information_schema.table_constraints t
JOIN information_schema.key_column_usage k USING (constraint_name,table_schema,table_name)
WHERE t.constraint_type='PRIMARY KEY' AND t.table_schema='db' AND t.table_name=tbl'