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 Link to comment https://forums.phpfreaks.com/topic/190900-help-selecting-from-mysql/ Share on other sites More sharing options...
Illusion Posted February 4, 2010 Share Posted February 4, 2010 What is your question here? Link to comment https://forums.phpfreaks.com/topic/190900-help-selecting-from-mysql/#findComment-1006705 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 Link to comment https://forums.phpfreaks.com/topic/190900-help-selecting-from-mysql/#findComment-1006709 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. Link to comment https://forums.phpfreaks.com/topic/190900-help-selecting-from-mysql/#findComment-1010507 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.