fix mysql count with a better search.