Re: Using the AS key word in SQL Queries
| From: | Richard Lynch | Date: | Tue, 02 Jul 2002 09:19:40 +0000 |
| Subject: | Re: Using the AS key word in SQL Queries | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-104883@lists.php.net to get a copy of this message | ||
>On Tue, Jul 02, 2002 at 11:08:13AM +0530, Sachin Keshavan wrote:
>>
>> I am trying to execute the Query
>> SELECT MAX(RECORDNO) AS MAXREC FROM BOOKS;
>>
>> while($row = mysql_fetch_array($sql_result))
>> {
>> $bookID = $row['MAXREC'];
>> }
>>
>> This query fails. Am I doing any thing wrong here.
Warning: In addition to any SQL error you may have, you almost-for-sure are
making a newbie logical flaw in your programming.
Let me ask you this question:
What if *TWO* (2) people add new books at *EXACTLY* the same time?
Do you *STILL* want the MAX(RECORDNO) ?
Or am I gonna get the other guy's book, since his went in a micro-second
after mine did?
:-)
You may want to look into this function:
http://www.php.net/manual/en/function.mysql-insert-id.php
I could, of course, be wrong, and you're not making the same mistake a
million others have made before... :-)
--
Like Music? http://l-i-e.com/artists.htm