天天看點

mySql中count帶條件查詢

方法一:

SELECT
	count(
		t.command_name = 'UNLOCK'
		OR NULL
	) unlockFrequency
FROM
表 t
           

方法二:

select count(t.command_name) from t where t.command_name = 'UNLOCK'
           

方法三:

select count(if( t.command_name = 'UNLOCK' ,1,null)) from t