实现这一目标的最佳方法是什么?
答案 0 :(得分:0)
如果您只想要具有特定电子邮件地址的同一电子邮件地址的用户的信息,您可以这样做:
SELECT * FROM users WHERE email = "whatever";
猜测您有一个名为email
的列。使用此声明,您将拥有具有相同电子邮件的所有记录。
如果您想知道数据库中的特定电子邮件地址是否重复,您可以使用另一个声明:
SELECT COUNT(*) AS numberDuplicates FROM users WHERE email = "whatever";
您可以使用numberDuplicates
值来了解此电子邮件是否重复。
答案 1 :(得分:0)
试试这个:
SELECT * FROM users WHERE email_address IN
(
SELECT email_address FROM users
GROUP BY email_address HAVING COUNT(*) > 1
)
如果您只想要针对每个电子邮件地址的用户数量超过1个条目,请运行以下命令:
SELECT email_address, COUNT(*) AS number_of_entries
FROM users
GROUP BY email_address
HAVING COUNT(*) > 1
答案 2 :(得分:0)
$product_groups = mysql_query("SELECT * FROM products GROUP BY ProductId ORDER BY id");
while($productGroups_fetch = mysql_fetch_array($product_groups, MYSQLI_ASSOC))
{
$product_images = mysql_query("SELECT ImageSource FROM products WHERE ProductId = 8");
while($fetch_product_image = mysql_fetch_array($product_images, MYSQLI_ASSOC))
{
}
}