Selecionar registros por ano.

Seguindo a serie “BUSCAS”, alguem chegou ao blog buscando “mysql pesquisa por year”. vamos à solução:

mysql> SELECT * FROM tb_table where YEAR(tbl_data)=’2007?

Essa consulta traz todos os registros com ano = 2007, é claro o campo deve ser DATETIME,DATE ou TIMESTAMP

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.