1582错误问题调用本机函数时参数计数不正确'ISNULL'

error problem with 1582 Incorrect parameter count in the call to native function 'ISNULL'

我有 2 个表,一个(访问)和另一个(患者)与 mysql(患者)的关系是 PK 作为 patients.pid 和 visits.pid 作为索引 我想在我的 vb.net 应用程序中使用代码来获取最后的日期时间记录,以检查患者是否仍在医院内入院或出院 到目前为止,我在你们的帮助下有了这段代码

SELECT a.pid,MAX(ISNULL(b.sdat,'1901-01-01')),MAX(ISNULL(b.edat,'1901-01-01')) from patients a left join visits b on a.pid=b.pid Where ddatediff(now(),b.edat) <=365 group by a.pid

但是当我使用 php myadmin 或其他应用程序在 sql 构建器中执行时,出现错误 (1582 - 调用本机函数时参数计数不正确 'ISNULL') 我试图找出错误原因,但直到现在都没有运气

MySQL's ISNULL() is a comparison function, that takes a single argument and returns 1 if it is NULL. I think that you meant IFNULL() - or the more standard COALESCE().

我还建议将检查移到聚合函数之外,以提高效率:

COALESCE(MAX(b.sdat),'1901-01-01'),
COALESCE(MAX(b.edat),'1901-01-01')