RE: [PHP-DB] Getting a result from MAX() query
Sadly, I don't have any answers, only more questions. First, how do you know your query is returning a FALSE result? What test are you performing and what are the results of the test? Second, what type of column is fee_recd? I've been toying with the MAX() function on the command line with a number of my own tables using different column types (DATE, TEXT, VARCHAR, INT) and have yet to see it fail to return some sort of result set. Rich -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 13, 2004 8:57 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Getting a result from MAX() query Would somebody be kind enough to explain why this query produces a false result $latest=mysql_query(SELECT MAX(fee_recd) FROM members,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); but this one doesn't $latest=mysql_query(SELECT fee_recd FROM members ORDER BY fee_recd DESC LIMIT 1,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); Louise -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Getting a result from MAX() query
Usually you need to group on something for a max to work (at least in Oracle) -Original Message- From: Hutchins, Richard [EMAIL PROTECTED] Sent: Jul 13, 2004 8:40 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] Getting a result from MAX() query Sadly, I don't have any answers, only more questions. First, how do you know your query is returning a FALSE result? What test are you performing and what are the results of the test? Second, what type of column is fee_recd? I've been toying with the MAX() function on the command line with a number of my own tables using different column types (DATE, TEXT, VARCHAR, INT) and have yet to see it fail to return some sort of result set. Rich -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 13, 2004 8:57 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Getting a result from MAX() query Would somebody be kind enough to explain why this query produces a false result $latest=mysql_query(SELECT MAX(fee_recd) FROM members,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); but this one doesn't $latest=mysql_query(SELECT fee_recd FROM members ORDER BY fee_recd DESC LIMIT 1,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); Louise -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - Dylan Barber : AOL Messenger - dylanbarb (CIW Professional, A+ Technician): MSN Messenger - [EMAIL PROTECTED] Web Designer / Developer / Host - Clip those URLs! - Short links are easier to remember. http://clipurl.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Getting a result from MAX() query
[EMAIL PROTECTED] wrote: Would somebody be kind enough to explain why this query produces a false result $latest=mysql_query(SELECT MAX(fee_recd) FROM members,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); but this one doesn't $latest=mysql_query(SELECT fee_recd FROM members ORDER BY fee_recd DESC LIMIT 1,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); Louise Here's a concept: RTM In MySQL versions prior to Version 3.22.5, you can use MAX() instead of GREATEST. What does your inquiry have to do with PHP? Doug -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Getting a result from MAX() query
[EMAIL PROTECTED] wrote: Would somebody be kind enough to explain why this query produces a false result $latest=mysql_query(SELECT MAX(fee_recd) FROM members,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); Would you be kind enough to tell us what text mysql_error() shows? You probably just need to use an alias in your query: SELECT MAX(fee_recd) AS max_fee_recd FROM members and then you'll have $row['max_fee_recd'] when you fetch the value from your result set. Other wise you need to use $row['MAX(fee_recd)']... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php