Hi,
I have a table like this:
mysql> select id, ticketid, rdvwhen from rdv  order by ticketid asc, id 
desc;
+----+----------+----------------+
| id | ticketid | rdvwhen        |
+----+----------+----------------+
|  1 |       18 | 20010503090000 |
|  2 |       20 | 20010430153000 |
|  7 |       30 | 20010517090000 |
|  6 |       31 | 20010514090000 |
| 15 |       32 | 20010521140000 |
| 12 |       33 | 20010523133000 |
|  5 |       33 | 20010515130000 |
|  4 |       35 | 00000000000000 |
| 14 |       36 | 20010518140000 |
|  3 |       36 | 20010509090000 |
|  8 |       37 | 20010521090000 |
| 13 |       38 | 20010522140000 |
|  9 |       41 | 20010522093000 |
| 10 |       42 | 20010517140000 |
| 16 |       44 | 20010528140000 |
+----+----------+----------------+
15 rows in set (0.00 sec) 

I'd like to filter this so that the "ticketid" is unique. If there are 
multiple identical "ticketid"s I'd like to get the one where the "id" field 
is the biggest. 

This is in fact only one step to accomplish the following: 

$table1=tickets;
$table2=rdv; 

SELECT   $table1.id, $table1.firstmsgid, $table1.customerid, 
$table1.creator,
        $table1.assigneduserid, $table1.statusid, $table1.priorityid, 
$table1.travail,
        $table1.bpdfile, $table1.bpduser, $table1.typeoftask,
        UNIX_TIMESTAMP($table1.created) AS created, 
UNIX_TIMESTAMP($table1.bpdwhen) AS bpdwhen
FROM $table1     LEFT JOIN $table2 ON ($table1.id = $table2.ticketid) <--*
WHERE (statusid = '$sid')
GROUP BY $table1.customerid
ORDER BY $table2.rdvwhen ASC 

* I'd like to join to the above criteria only (field with largest id only if 
there are multiple ticketid)... 

regards, 

 ---
J.M. Roth 

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to