Jump to content

Why am I getting No results?


SalientAnimal

Recommended Posts

Hi All,

 

I am runningt his query to count and then display the current date's records captured. Even thoguh I know there are records captured, why am I still getting no results?

 

$result = mysql_query("SELECT * FROM cs_2012
WHERE 
sys_date = CURRENT_DATE()");
$num_rows = mysql_num_rows($result);

echo "$num_rows Rows\n";

Link to comment
Share on other sites

If you're getting no results then there aren't any records being "captured". Try running your query using some tool like phpMyAdmin or MySQL Workbench.

 

 

I've run the query using a like function and then using today's date and I am getting results, however, I don't want to have to update the query everyday.

 

$result = mysql_query("SELECT * FROM cs_2012WHERE sys_date = like '2012-06-25%'");$num_rows = mysql_num_rows($result);echo "$num_rows Rows\n";

 

The above query returns 270 Rows. But when using CURDATE() or CURRENT_DATE() it says 0 Rows

Link to comment
Share on other sites

Ok, so I finally after lots of trial nad error got this to work.

 

I can only assume that the reason I wasn't getting any results is because my sys_date column is a TIMESTAMP field.

 

Here's the solution:

 

$result = mysql_query("
SELECT * FROM cs_2012
WHERE 
DATE(sys_date) = CURDATE()
");
$num_rows = mysql_num_rows($result);

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.