|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Getting the max values records
Hi all, do help me...
I have a table with these fields... id | line | header | description = | === | ===== | ========= 1 | hi | good |how are you? 2 |U | wow |how is your class? 3 |me |trouble |problem with fetching records etc.... the id is auto incremented as and when the records are inserted. Now the problem is once, I want to fetch the record, then the id with the maximum number should be displayed. the query works fine if it is with individual statements like select max(ad_id) as Idd from pbl_content or select ad_id, ad_top_line, ad_header, ad_description from pbl_content. I want to get the value of the id with the max value and once I write the coding the error coming is Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in and my query is select ad_top_line, ad_header, ad_description from pbl_content where ad_id=max(ad_id) Last edited by Black : September 7th, 2004 at 07:26 AM. Reason: alignment |
|
#2
|
|||
|
|||
|
If you order the results by id descending and limit the results to 1 this should achieve that effect. Something like (this is bound to be a bit off as I have no way of testing it) -
SELECT ad_top_line, ad_header, ad_description from pbl_content ORDER BY ad_id DESC LIMIT 1 Hope this helps, -KM- |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Getting the max values records |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|