我正在进行此查询,但它返回空,我需要返回0,我一直在阅读它,似乎有IFNULL函数,这可以解决,但mysqlWorkbench标记语法错误。
希望有人能帮助我。谢谢SELECT IF NULL( "00:00:00", "03:00:00", count(*)
FROM
compose.TBL_USERS_TAGS ut join
compose.TBL_USERS u on ut.ID_USER = u.ID_USER join
compose.TBL_TAGS t on ut.ID_TAG = t.ID_TAG join
compose.TBL_IN_OUT i on i.TAG_ADDRESS = t.TAG_ADDRESS join
compose.TBL_EVENTS e on e.TAG_ADDRESS = i.TAG_ADDRESS
WHERE (((TIMESTAMPDIFF(SECOND, e.CREATION_DATE,i.IN_DATE)) <='00:02:00' AND
(TIMESTAMPDIFF(SECOND, e.CREATION_DATE, i.IN_DATE)) >= '00:00:00' ))OR
(e.CREATION_DATE > i.IN_DATE AND e.CREATION_DATE < i.OUT_DATE) AND
(TIMESTAMPDIFF(SECOND, i.in_date,i.out_date)) >= '00:00:20' AND
(convert(i.IN_DATE, TIME) >= "00:00:00" AND convert(i.OUT_DATE, TIME) <= "03:00:00")
GROUP BY "00:00:00", "03:00:00",0);
答案 0 :(得分:0)
我认为应该是这样的:
SELECT IFNULL(field_name,“value”);