Jump to content

Difficult WHERE clause


Xtremer360

Recommended Posts

$query = "SELECT * FROM `top5` WHERE `lastUpdated` = ?";

 

What I'm trying to do is check it again the lastUpdated table and make sure there isn't a row with the same date AND MONTH as an already existing row.

 

Any ideas how to accomplish this. And yes I have lastUpdated as a date field type.

Link to comment
Share on other sites

Ok so when entering things into your lastupdated table i would do it like this:

 

$date = time(); // returns somthing like 1303156571

 

then when you query in another file to see if anything has been "last updated" on the current day you would do;

$current_date = time();

$sql = "SELECT * FROM top_5 WHERE lastupdated =".$current_date;

Link to comment
Share on other sites

Actually with the help of a good friend I was able to come up with what I needed and here it is hopefully for anyone can understand this and apply it if need be.

 

WHERE year(`lastUpdated`) = year(now()) AND month(`lastUpdated`) = month(now())

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.