I have a problem on sorting by alphabet but I want the name with [duplicate] sort at last What I would like to have is at first would sort by alphabet then name with duplicate sort at last. The duplicate might be more than 1.
The result I have done:
$sql = 'SELECT DISTINCT venue_id, name FROM venues ';
$sql .= 'ORDER BY CASE ';
$sql .= 'WHEN name NOT LIKE "%[DUPLICATE]" THEN "1" ';
$sql .= 'WHEN name LIKE "%[DUPLICATE]" THEN "100" ';
$sql .= 'END ASC ';
*----------*------------------*
| ID | venue_name |
*----------*------------------*
| 1 | Axxxx |
| 2 | Assss |
| 5 | Assss [duplicate]| // this is actually the whole name of the venue
| 6 | Bzzzz |
| 7 | Bzzzz [duplicate]|
| 8 | Fzzzz |
| 21 | Fzzzz [duplicate]|
*----------*-----------------*
is it posible for the result be like:
*----------*------------------*
| ID | venue_name |
*----------*------------------*
| 1 | Axxxx |
| 2 | Assss |
| 6 | Bzzzz |
| 8 | Fzzzz |
| 5 | Assss [duplicate]|
| 7 | Bzzzz [duplicate]|
| 21 | Fzzzz [duplicate]|
*----------*-----------------*
Aucun commentaire :
Enregistrer un commentaire