DISTINCT question

Discussion in 'PHP' started by Greenmethod, Dec 7, 2007.

  1. #1
    My sql query is:

    mysql_query("SELECT DISTINCT `call_no`,`problem`,`date`,`status`,`spoke_with` FROM `comments` WHERE `cust_no`='$cust_no'")
    PHP:
    What I want to do is select only call_no as distinct, not everything else, so if there are 4 different entries for call number 2, it will only come up once but have all the other info.

    Right now, it is getting every entry because the date is different in all of them.
     
    Greenmethod, Dec 7, 2007 IP
  2. drunnells

    drunnells Peon

    Messages:
    79
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If I understand what you are looking for then GROUP BY might be what you want:

    SELECT call_no,problem,date,status,spoke_with FROM comments WHERE cust_no='$cust_no' GROUP BY call_no

    then you will receive only one row for each call_no.
     
    drunnells, Dec 7, 2007 IP