set sender_id =(选择EXISTS(SELECT 1 FROM account
WHERE account_id = p_sender_id));
set viewer_id =(选择EXISTS(SELECT 1 FROM account
WHERE account_id = p_viewer_id));
答案 0 :(得分:0)
您可以执行以下操作:
SELECT EXISTS(SELECT 1 FROM account WHERE account_id = p_sender_id)),
EXISTS(SELECT 1 FROM account WHERE account_id = p_viewer_id))
INTO sender_id, viewer_id;
详细了解SELECT...INTO。
重新评论:
如果要运行一个子查询来设置两者:
SELECT
MAX(CASE account_id WHEN p_sender_id THEN 1 ELSE 0 END),
MAX(CASE account_id WHEN p_viewer_id THEN 1 ELSE 0 END)
INTO sender_id, viewer_id
FROM account
WHERE account_id IN (p_sender_id, p_viewer_id);