rcouser Posted February 4, 2010 Share Posted February 4, 2010 Hello, I have 2 queries that I need help with. Firstly my database tables are as follows: Table One: News news_id: 1 news_title: Lorem ipsum dolor sit amet consectetur adipiscing date_created: 2010-01-26 16:37:47 news_tags: 1,2,3,4 Table Two: Tags tag_id: 1 tag_name: UK tag_id: 2 tag_name: Wind tag_id: 3 tag_name: Offshore tag_id: 4 tag_name: Coal Query One SELECT news_id, news_title, DATE_FORMAT(date_created, '%d/%m/%y') AS date_created FROM news WHERE date_created = this month and year ORDER BY date_created DESC Query Two SELECT news_id, news_title, DATE_FORMAT(date_created, '%d/%m/%y') AS date_created FROM news WHERE tag_id = selected tag (e.g. 1) ORDER BY date_created DESC Any help would be much appreciated. Regards Quote Link to comment Share on other sites More sharing options...
Illusion Posted February 4, 2010 Share Posted February 4, 2010 What is your question here? Quote Link to comment Share on other sites More sharing options...
rcouser Posted February 4, 2010 Author Share Posted February 4, 2010 Query One SELECT news_id, news_title, DATE_FORMAT(date_created, '%d/%m/%y') AS date_created FROM news WHERE date_created = this month and year ORDER BY date_created DESC Query Two SELECT news_id, news_title, DATE_FORMAT(date_created, '%d/%m/%y') AS date_created FROM news WHERE tag_id = selected tag (e.g. 1) ORDER BY date_created DESC Quote Link to comment Share on other sites More sharing options...
fenway Posted February 11, 2010 Share Posted February 11, 2010 MySQL has many date functions -- including MONTH() and YEAR(). Not sure what you want for the second one. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.