Jump to content

Help selecting from mysql


rcouser

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.