Hi,
I have a table that contains something like follows:

id       prop_name           status           action_date           
 prop_type             address
1         name1                  ok                 2001-12-12           
 1                           addy1forname1
2         name2                  ok                 2001-12-13           
 1                           addy1forname2
3         name1                  ok                 2001-12-13           
 1                           addy2(new)forname1
4         name3                  ok                 2001-12-14           
 2                           addy1forname3
5         name2                  ok                 2001-12-13           
 1                           addy2(new)forname2

If I am looking for all prop_names of type=1 I must get the following 
list only:

name1 with id=3 and
name2 with id=5. the other name1's and name2's and name3 should not be 
included as they are either older or not of type 1. Also, another twist. 
The name1 and name2 should only be listed if their action_date is not 
older than 52 weeks (1 year).

A bit more background to clarify.

The table holds data for properties which gets updated from time to 
time. I have a search function on a website using php that allows the 
user to search for all type 1's and I only want the latest entry for 
each prop_name to appear on the list and only if the data is not older 
than a year.

My existing code works fine, but it doesn't work when a new entry is 
made to the table ( it shows both or all of the previous entries as 
well). I am looking for an sql string solution here that will only 
return the rows I'm looking for as I have already written all the code 
to run through these rows and create hyperlinks etc, so I would ideally 
not want to change that if possible. So, basically my problem is that my 
current sql string returns "incorrect" rows along with correct ones and 
I would like to remove the incorrect ones by using a different sql 
string rather than write more if's and then's to try to sort out which 
rows are garbage and which should be echoed.

Thanks alot.
Please yell if I can make the problem more clear.






---------------------------------------------------------------------
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