How to make a query to show duplicated row by a field

Discussion in 'PHP' started by baris22, Jan 13, 2009.

  1. #1
    hello,

    this is my query.

    
    $query = "SELECT id, title, description FROM web ORDER BY list_number DESC LIMIT $start, $limit";
    
    PHP:
    how can i display only the fields which has got the same information on list_number?


    thanks
     
    baris22, Jan 13, 2009 IP
  2. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use GROUP BY. I'm not sure what you wanna do exactly.. try explaining a bit better :)
     
    xlcho, Jan 14, 2009 IP
  3. yoavmatchulsky

    yoavmatchulsky Member

    Messages:
    57
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #3
    i think you mean:

    SELECT .. FROM web WHERE list_number = 2 ..

    2 is the list number your want all the records for
     
    yoavmatchulsky, Jan 14, 2009 IP
  4. osmasters

    osmasters Well-Known Member

    Messages:
    453
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    100
    #4
    You may want to see only duplicate row by title and description.

    I hope this will help you.

     
    osmasters, Jan 15, 2009 IP
  5. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #5
    Very hard to understand what your looking for, but .. You can always use WHERE statement !
     
    ActiveFrost, Jan 15, 2009 IP
  6. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #6
    ok...

    this is the database

    id title description list_number

    1 fjgh ritururgrf 2234
    2 ooiyt googorg 314
    3 weerrddd fdfdfdf 344533
    4 aqwwsd oopthgh 314


    I only want to display dublicate entries on list_number. So the output must be:

    id title description list_number


    2 ooiyt googorg 314
    4 aqwwsd oopthgh 314

    Thanks
     
    baris22, Jan 15, 2009 IP
  7. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #7
    $qry = mysql_query("SELECT id, title,description,list_number FROM table1 GROUP BY id, title,description,list_number HAVING COUNT(list_number) >1")
    PHP:
     
    ActiveFrost, Jan 15, 2009 IP