harleydude Posted November 9, 2006 Share Posted November 9, 2006 I have a table with some data like this:Type Null Default cpindex int(6) No cpid int(3) No 0 cpcid int(3) No 0 cpcust varchar(30) No 0 cprsm char(3) No cpprice float No 0 cpqty int(9) No 0 cpdate date No 0000-00-00 cpquote int(3) No 0 Indexes: Keyname Type Cardinality Field cpindex INDEX None cpindex cpid cpcid INDEX None cpcid cpid INDEX None cpid very simple data table, now the users have populated it with various amounts of data where the application will set the date to the current date (date data was enterred:Y-m-d format). So we have loads of data in the table where common items may have multiple entries on different days (we won't talk about multiple entries on the same day... users, egads!!). Ok, so far so good.Now, what I need to do is look at this database and get all of the most recent entries, en mass. The criteria to get the recordset is:cpid - product idcpcid - customer idi need all records with the most recent date by product group. What is the most efficient method of doing this?(using the select max(cpdate), * from cptable where cpid= $val and cpcid = $cval does not work).Thanks guys. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 10, 2006 Share Posted November 10, 2006 You mean return the most recent entry for each product group? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.