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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.