HI
This is possibly very easy, but I can't seem to get it right.
I have a table that hold some data about properties. The data gets 
updated from time to time, but each time a new "update" is done, it 
get's a new row. The only thing in some cases setting the different 
entries appart is an "action_date" field I added that holds the date of 
the entry. The reason why I make a new entry is to keep a record of each 
time I receive data about a property for future reference. Now, my 
problem. I need to pull the data for a specific property (prop_name) 
that is a) not older than 52 weeks from the current date b) must have 
"success" in the "status" field, and c) must be the latest entry in case 
there are more than one entry for the same property matching all these 
criteria ( thus, I could have received a new entry within the 52 week 
period).
So, how would the query string look that would only return ONE set of 
data for that specific property?
A possible solution from a different source suggest the following, but 
I'm not sure it will work as it looks to me as if it still returns more 
than one row(possibly).

$sql = "select * from table where prop_name='$prop_name' and 
prop_type='$prop_type' and status='success' and 
action_date>('".date("Y-m-d")."',INTERVAL 12 MONTH group by ID order by 
action_date desc)";

PS, This is for a PHP page, but I guess it won't matter right?



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to