massive Posted March 7, 2006 Share Posted March 7, 2006 Hi guyz...its me again heheheh....i was wondering how to view only the recent data by refferring to its date my querying seems to be wrong...For example:a customer paid at the date of 2006-03-02...this is the last time he paid....so when i view his information the most recent date would be or should be view "2006-03-02"...not 2006-03-01...not 2006-02-28....etc...$query = "SELECT * FROM dataz WHERE username = '$username' AND Dated = MAX(Dated) AS most";"in here i have errors i know my placing of "max(date) as most" is wrong...this comes in handy if i do this"$query = "SELECT *, MAX(Dated) AS most FROM dataz WHERE username = '$username'";"i was wondering how could i do this in terms of using WHERE....."Algorithm: Select everything from dates where this is the user and the date of the user is the most recent...tnx...^__^ Quote Link to comment Share on other sites More sharing options...
shocker-z Posted March 7, 2006 Share Posted March 7, 2006 instead of usingSELECT *, MAX(Dated) AS most FROM dataz WHERE username = '$username'You could try and use:SELECT TOP 1 * FROM dataz ORDER BY dated DESCthat will order the date so latest is at the top and just select that single record.. i think :) Quote Link to comment Share on other sites More sharing options...
massive Posted March 7, 2006 Author Share Posted March 7, 2006 [!--quoteo(post=352445:date=Mar 7 2006, 05:43 AM:name=shocker-z)--][div class=\'quotetop\']QUOTE(shocker-z @ Mar 7 2006, 05:43 AM) [snapback]352445[/snapback][/div][div class=\'quotemain\'][!--quotec--]instead of usingSELECT *, MAX(Dated) AS most FROM dataz WHERE username = '$username'You could try and use:SELECT TOP 1 * FROM dataz ORDER BY dated DESCthat will order the date so latest is at the top and just select that single record.. i think :)[/quote]about the "TOP 1" thing is that the same with "LIMIT 1"?...anyways thanks shocker-z ^__^ 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.