Re: adding a simple WHERE clause to this MySQL query causes the result to contain 0 rows?!
| From: | gunawan | Date: | Mon, 10 Aug 2009 17:11:35 +0000 |
| Subject: | Re: adding a simple WHERE clause to this MySQL query causes the result to contain 0 rows?! | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46433@lists.php.net to get a copy of this message | ||
read 2nd something not right.. or should show ERRORRR?? but. let's skip it.. i think you tried it and work.. soo ignore this line.
uniqueDate??
why not order by id.. is the same right?
can you include sample from those table.. hope we can try at home and try to figure it out? John Butler wrote:It seems super easy to me; great.. i need 1 hour to understand this
Can anyone see what must be a simple error in the way I am trying to construct the 2 WHERE clauses, below? (in the latter query) These two columns in the two separate tables are of type TIMESTAMP: solarLandingDateTime solarAWDateTime The values I am passing into the query are like so var_dump($userPikStartDate); // string(10) "2009-08-04" var_dump($userPikEndDate); // string(10) "2009-08-09" This query works as expected and returns all my rows: (including ones where the 'solarLandingDateTime' or 'solarAWDateTime' column contains a TIMESTAMP like '2009-08-09 03:14:07' -------- $query = "SELECT COUNT(*) ASCountRows_UNIQdateTblDir, date(solarLandingDateTime) ASuniqueDate, solarLandingDir AStrackingDir, 't7solar_landing' AStableAliasFROM t7solar_landing GROUP BY date(solarLandingDateTime), solarLandingDir UNION ALL SELECT count(*) ASCountRows_UNIQdateTblDir, date(solarAWDateTime) ASuniqueDate, solarAWfm_meta_adtracking AStrackingDir, 'aweber_7solar_aw' AStableAliasFROM aweber_7solar_aw GROUP BY date(solarAWDateTime), solarAWfm_meta_adtracking ORDER BY uniqueDate DESC LIMIT 300"; But thisquery returns zero rows: -------- $query = "SELECT COUNT(*) ASCountRows_UNIQdateTblDir, date(solarLandingDateTime) ASuniqueDate, solarLandingDir AStrackingDir, 't7solar_landing' AStableAliasFROM t7solar_landing WHERE date(solarLandingDateTime) >= $userPikStartDate AND date(solarLandingDateTime) <= $userPikEndDate GROUP BY date(solarLandingDateTime), solarLandingDir UNION ALL SELECT count(*) ASCountRows_UNIQdateTblDir, date(solarAWDateTime) ASuniqueDate, solarAWfm_meta_adtracking AStrackingDir, 'aweber_7solar_aw' AStableAliasFROM aweber_7solar_aw WHERE date(solarAWDateTime) >= $userPikStartDate AND date(solarAWDateTime) <= $userPikEndDate GROUP BY date(solarAWDateTime), solarAWfm_meta_adtracking ORDER BY uniqueDate DESC LIMIT 300"; ?? Thanks for taking a look. It seems super easy to me; I don't see why it doesn't work. -John