Deprecated: Function strftime() is deprecated in /home/hosting/awbinformatica_it/www/php/lib/risorse.common.lib.php on line 280
AWB Informatica - MySQL istruzione CASE in una query

MySQL istruzione CASE in una query

04 March 2012

Supponiamo di avere una tabella MySQL denominata "scuole" ed in base al valore del campo tipologia vogliamo selezionare una particolare descrizione:
mysql> SELECT tipologia,
    ->    CASE tipologia
    ->       WHEN 'a' THEN 'ha aderito'
    ->       WHEN 'n' THEN 'non adersce'
    ->       WHEN 'nc' THEN 'non nel campione'
    ->       ELSE 'altra tipologia'
    ->    END AS tipo
    -> FROM scuole limit 0,8;

+--------------+------------------+
| tipologia    | tipo             |
+--------------+------------------+
| c            | altra tipologia  |
| nc           | non nel campione |
| a            | ha aderito       |
| nc           | non nel campione |
| nc           | non nel campione |
| n            | non aderisce     |
| nc           | non nel campione |
| nc           | non nel campione |
+--------------+------------------+
8 rows in set (0.00 sec)


Deprecated: Function strftime() is deprecated in /home/hosting/awbinformatica_it/www/php/template/page_template.php on line 556

Deprecated: Function strftime() is deprecated in /home/hosting/awbinformatica_it/www/php/template/page_template.php on line 556

Deprecated: Function strftime() is deprecated in /home/hosting/awbinformatica_it/www/php/template/page_template.php on line 556

Deprecated: Function strftime() is deprecated in /home/hosting/awbinformatica_it/www/php/template/page_template.php on line 556

Deprecated: Function strftime() is deprecated in /home/hosting/awbinformatica_it/www/php/template/page_template.php on line 556

Deprecated: Function strftime() is deprecated in /home/hosting/awbinformatica_it/www/php/template/page_template.php on line 556