Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个名为的表,因为holidays我想根据年份过滤行。我的数据库表是这样的,
holidays
2013-09-25 2013-09-12 2014-01-15 2014-05-15
我只想要年份开始的列值2013?
2013
SELECT * FROM holidays WHERE YEAR(`date_field`) = YEAR(NOW())
您还可以使用LIKE运算符:
LIKE
SELECT * FROM holidays WHERE YEAR(date_field) LIKE '%2013%'
这是SQLFiddle