【发布时间】:2017-04-10 01:04:34
【问题描述】:
这是我的数据库:
table 1: dog
column 1: email
column 2: password
table 2: cat
column 1: email
column 2: password
我想检查一个字符串或数据是否已经存在于两个数据库的列中:
//check if email exists in either dog or cat.
$stmt = $dbh->prepare("SELECT email FROM dog AND cat WHERE email = :email");
$stmt->bindParam(':email', $email);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
//if the email exists in either dog or cat, echo the "taken" message below
if($row['email'] == $email) {
echo "sorry, the email is taken already!";
}
但这对我不起作用。我怎样才能让它工作?
【问题讨论】:
-
在两者的列中是 OR 不是 AND
标签: php mysql database select pdo