Re: newbie: how to return one iteration *per unique date (DAY!)* in a timestamp column?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



.. so my thought is to want to do nested query(ies),  where:
*within* the while loop of the first recordset (which is now
successfully returning just rows with unique dates), I do other
query(ies) which will (in their own code block) find all rows of the
date we are iterating.. so I can, for example, count number of records
for each unique date, do math/statistics, etc.

I had to do something similar in code of my own a little while ago, and got some very good guidance on Stack Overflow. Here's the thread, you might find it
helpful:

http://stackoverflow.com/questions/946214/one-sql-query-or-many-in-a-loop

The user whose answer is marked as the correct one ("Quassnoi") also writes a helpful blog on SQL. You should be able to find the blog by clicking on the
username.

Ben

Thanks Ben.  And yes Jack,

..I was attracted to the nested query as that required less new SQL ground to learn right now while I am expected to produce! But as that user (and others in that thread you gave, Ben) said, "better to learn to do things the right way".

So I need to read/learn more MySQL. Can you guys point me to where in the mysql docs I should be burying myself?

Here's what I am trying to do:

I have a table created by this:
$SQL="CREATE TABLE t7solar_landing (solarLandingDateTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP PRIMARY KEY,solarLandingDir TINYTEXT,solarLandingIP TINYTEXT)";

and other tables too, like this:
$SQL="CREATE TABLE aw_7solar_confirm (solarAwConfDateTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP PRIMARY KEY,solarAwConfIP TINYTEXT)";

and this:
$SQL="CREATE TABLE aw_7solar_aw (solarAWDateTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP PRIMARY KEY,solarAWIP TINYTEXT,solarAWfm_email TINYTEXT,solarAWfm_meta_adtracking TINYTEXT, ... (plus more columns)";


I need to query these 3 tables (in one query! ;-) ...to return to me: one iteration of a while loop...

...which will echo:
"<tr><td>#records in 't7solar_landing' matching the given (iterating) date (in the 'solarLandingDateTime' column)</ td><td>#records in 'aw_7solar_confirm' matching the given (iterating) date (in the 'solarAwConfDateTime' column)</td><td>#records in 'aw_7solar_aw' matching the given (iterating) date (in the 'solarAWDateTime' column)</td></tr>"...

...*per unique DATE* found in the 'solarLandingDateTime' column of the 1st (t7solar_landing) table.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux