我有以下查询从表格user_id
获取profiles
,其中 profile.status wip / rejected / canceled ,他们的 user_activity_log.last_activity 时间超过1分钟之前:
SELECT t1.user_id
FROM profiles t1
INNER JOIN user_activity_log t2
ON t1.user_id = t2.user_id
WHERE t1.status IN ('wip','declined','cancelled')
AND t2.last_activity < NOW() - INTERVAL 1 MINUTE
这按预期工作,但我现在要做的是包括:
INNER JOIN email_logs t3
ON t1.user_id = t3.user_id AND t3.sent_datetime < NOW() - INTERVAL 1 MINUTE
但是如果该表中存在user_id
(email_logs
),我只希望这种连接发生,否则返回初始查询的结果。
我该怎么做?
非常感谢
答案 0 :(得分:1)
您可以使用<?php
$email = $_POST['email'];
if ($email == 'gmail email' ) {
header('Location: /gmailusers');
} elseif ($email == 'hotmail email') {
header('Location: /liveusers');
} else {
header('Location: /unknownusers');
}
?>
执行此操作,但子查询中的条件稍有变化:
NOT EXISTS