Visualizzazione dei risultati da 1 a 5 su 5

Discussione: Mysql Order by letter

  1. #1

    Mysql Order by letter

    Ciao,
    Ho una select tipo questa
    SELECT DISTINCT `country`
    FROM `nations`
    GROUP BY `country`


    be vorrei avere Italy al primo posto
    è possibile ?


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  2. #2
    Utente di HTML.it L'avatar di nicola75ss
    Registrato dal
    Nov 2004
    Messaggi
    12,922
    codice:
    SELECT country
    FROM nations
    GROUP BY country
    ORDER BY IF(country='italy',0,1),country
    Visto che raggruppi l'uso di distinct è superfluo.

  3. #3

    EDIT
    PS
    che tu sappia è + performante group by o distinct ?
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  4. #4
    Utente di HTML.it L'avatar di nicola75ss
    Registrato dal
    Nov 2004
    Messaggi
    12,922
    Non saprei. Non mi sono mai posto il problema.
    Per abitudine più che altro se posso farne a meno evito di usare distinct.

  5. #5
    Originariamente inviato da nicola75ss
    Non saprei. Non mi sono mai posto il problema.
    Per abitudine più che altro se posso farne a meno evito di usare distinct.
    e fai bene

    Don't use DISTINCT when you have or could use GROUP BY

    http://forge.mysql.com/wiki/Top10SQLPerformanceTips

    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.