表寄存器
键 | app |
---|---|
123 | insta |
您需要的WHERE
子句仅在SELECT
语句中有效,因此不要使用VALUES
,而是正确使用SELECT
和EXISTS
:
INSERT INTO inbox(EventSourceApplication, EventName, MessageId, MessageText, status)
SELECT 'fb1', 'appointmentbooked', 'CAR201246', 'SUCCESSFULL', 'nope'
WHERE EXISTS (SELECT 1 FROM register WHERE key='123' AND app = 'insta')
ON CONFLICT(MessageId) DO UPDATE SET
EventSourceApplication = EXCLUDED.EventSourceApplication,
EventName = EXCLUDED.EventName,
MessageText=EXCLUDED.MessageText;