RoMo RoMo - 11 months ago 36
SQL Question

How to select records based on duplicate values of a column?

  • I have a 'users' table in mysql database.

  • That table has duplicate entries of same user who has same email
    address as well but other information may vary.

  • So I want to select all records of duplicate email addresses so that
    I can have all the rows of a particular email address alltogether.

What is the best way to achieve this?

$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))