In a MySQL table I have a column that when I INSERT a row I use NOW() function on the date column.
So I'm wondering (and have been wandering on MySQL's maze of a website) if there is a simple way to select all the rows that belong to the year 2007 in example?
MySQL SELECT * rows per year (from column NOW() insert?
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: MySQL SELECT * rows per year (from column NOW() insert?
As usual I find what I'm looking for only after I spend $x time searching. 
I'm open to suggestions on any improvements on the query. I won't be selecting * as an afterthought.
Code: Select all
SELECT * FROM table_name WHERE column_name BETWEEN '2007-01-01 00:00:00' AND '2007-12-31 23:59:59'Re: MySQL SELECT * rows per year (from column NOW() insert?
Try this one out:
Code: Select all
SELECT *
FROM `myTable`
WHERE YEAR(myColumn) = 2007- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: MySQL SELECT * rows per year (from column NOW() insert?
That works too! Thanks! 