if (select authorized.on from authorized join log on( authorized.card_id =log.card_id)) = now() then
insert into entry(access) values('granted');
end if;
“select”返回日期。但是,如果我将它放在if语句中,该语句确实有效。
答案 0 :(得分:0)
执行相反的操作,使用INSERT
执行SELECT
,如果符合条件,SELECT
将返回值为'granted'
的行:
insert into entry(access)
select distinct 'granted'
from authorized
join log on (authorized.card_id = log.card_id)
where authorized.on = now()
如果永远不会满足SELECT
条件,则不会插入任何行。