表一
CREATE TABLE IF NOT EXISTS `tp_zxyygl` (
`zxgl_id` int(11) NOT NULL AUTO_INCREMENT,
`zxgl_lrname` int(10) NOT NULL,
`zxgl_mj` int(11) NOT NULL,
`zx_id` int(11) NOT NULL,
`zxgl_yytime` int(11) NOT NULL,
`zxgl_lrtime` int(11) NOT NULL,
`zxgl_name` varchar(10) NOT NULL,
`zxgl_phone` varchar(20) NOT NULL,
`zxgl_sex` int(1) NOT NULL,
`zxgl_age` int(2) NOT NULL,
`zxgl_zhenh` varchar(40) NOT NULL,
`zxgl_ksid` int(11) NOT NULL,
`bz_id` int(11) NOT NULL,
`zxgl_img` varchar(255) NOT NULL,
`zxgl_jz_uid` int(11) NOT NULL,
`zxgl_gjc` varchar(100) NOT NULL,
`zxgl_bz` varchar(255) NOT NULL,
`zxgl_status` int(1) NOT NULL,
`zxgl_doctor` int(1) NOT NULL,
`zxgl_jzname` varchar(10) NOT NULL,
`zxgl_dialogue` text NOT NULL,
`zxgl_jztime` int(11) NOT NULL,
`zxgl_treatment` int(1) NOT NULL,
`zxgl_hfjg` varchar(100) NOT NULL,
`hp_id` int(11) NOT NULL,
PRIMARY KEY (`zxgl_id`),
KEY `hp_id` (`hp_id`)
)
统计语句
select a.hp_id,b.hp_yyname as hp_name,count(case a.zxgl_status when 0 then 1 end) as yy from tp_zxyygl a LEFT JOIN tp_hospitalp b ON a.hp_id=b.hp_id where IF(a.hp_id=1,a.zxgl_mj<>5,1=1) AND IF(a.hp_id=2,a.zxgl_mj<>5,1=1) AND IF(a.hp_id=3,a.zxgl_mj<>5,1=1) group by a.hp_id
4W来条数据在服务器上面运行需要6秒多点时间
求帮忙看看哪里的问题