Jump to content

LIKE help with query please


simonjk

Recommended Posts

Hi,

 

I have a column in my mysql database which is a TIMESTAMP. This automatically updates each time an entry is made. The TIMESTAMP update is in the format YYYY-MM-DD HH:MM;SS.

 

I am trying to run the query below which retrieves data entered on a specific date from the table.

 

However, it seems that the query reads the first date that is similar and that is output (i.e. 2012-09-07, rather than look for the date that has been requests (say, 2012-09-09).

 

$daysresult = mysql_query("SELECT * FROM `hsgasjobsarchive` WHERE `Region`='Region' AND `Date` LIKE '$year-$month-$day_%'");

 

Am I doing something wrong in the like statement? I'd like the statement to ignore everything after $day.

 

Thanks in advance,

Simon

Link to comment
Share on other sites

Thanks for the replies, but I don't see how this will help as the format of the date in the Date column (from TIMESTAMP) is YYYY-MM-DD HH:MM:SS, e.g. 2012-09-08 10:20.22 ?

 

Can the AND DATE(Date) = '$date' statement take a wildcard? As I could discard anything after $date?

 

Thanks again,

Simon

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.