Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di henry78
    Registrato dal
    May 2001
    Messaggi
    1,264

    Problema con query e campo con nome numerico...

    Ciao a tutti, ho una tabella in mysql con un campo che si chiama '2011'

    Se eseguo la query seguente:
    SELECT data FROM tab_uno WHERE 2011 <= '2011-05-24' ORDER BY id DESC LIMIT 2

    ricevo l'errore:Unknown column '2011' in 'order clause'

    ... come posso specificare che 2011 è in realtà il nome del campo?

  2. #2

    Re: Problema con query e campo con nome numerico...

    Originariamente inviato da henry78
    Ciao a tutti, ho una tabella in mysql con un campo che si chiama '2011'

    Se eseguo la query seguente:
    SELECT data FROM tab_uno WHERE 2011 <= '2011-05-24' ORDER BY id DESC LIMIT 2

    ricevo l'errore:Unknown column '2011' in 'order clause'

    ... come posso specificare che 2011 è in realtà il nome del campo?
    prova così:
    SELECT data FROM tab_uno WHERE '2011' <= '2011-05-24' ORDER BY id DESC LIMIT 2

  3. #3
    Utente di HTML.it L'avatar di henry78
    Registrato dal
    May 2001
    Messaggi
    1,264
    Ho risolto specificando il nome della tabella:

    tab_uno.2011

    SELECT * FROM tab_uno WHERE tab_uno.2011 <= '2011-05-24' ORDER BY id DESC LIMIT 2


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.