只是想知道您是否可以从子查询中获取数据,即使主查询没有返回任何命中?
$query = "SELECT `affiliateID`, `password`, `companyName`, `contactName`,
(SELECT loginAttempts FROM lockoutRecord WHERE attemptedUsername = '$user' AND accountType = 'Affiliate' ) as attemptCount,
(SELECT lastAttemptTime FROM lockoutRecord WHERE attemptedUsername = '$user' AND accountType = 'Affiliate' ) as lastAttemptTime
FROM `affiliates` WHERE `email` = '$user' LIMIT 1";
在上面的示例中,用户的登录尝试在附属表中没有找到该用户的命中,但我仍然希望它从 lockoutRecord 返回 loginAttempts 以查看对该用户名进行了多少次尝试
谢谢参观。