Excellent. That is more efficient (one select statement) than what I was
trying to do.


-----Original Message-----
From: Miles Thompson [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 23, 2002 2:20 PM
To: Zach Curtis; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] # of Records in Table

Select your password field, and whatever other fields you need
    -mysql_num_rows() to capture the number of rows returned
    -mysql_data_seek() to position pointer on last row (remember indexing
starts at 0)
    -mysql_fetch_row() or mysql_fetch_array(), your choice, to return the

One select.

One bit of relational theory I always ignore, but have come to appreciate
as I gain experience, is the virtue of having a unique key on every table
in a database. If that's a key I can rely on to steadily increase in value,
so much the better.

Hope this helps and gets you out of your fix - Miles Thompson

At 01:52 PM 1/23/2002 -0700, Zach Curtis wrote:
>The last record should be whatever the last record is in the table. For
>example, if there are 1000 records in the table which COUNT(*) will tell
>how can I get the password for record 1000. The only thing I can do that
>would probably work is two query statements, one selecting COUNT(*) and the
>other selecting "password". What I don't like about this method is that I
>would have to retrieve all of the passwords into an array, which I would
>assume would be slow on larger tables. Ideally, I thought their would be a
>way to do this operation in one select statement. Any thoughts?
>-----Original Message-----
>From: DL Neil [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, January 23, 2002 1:11 PM
>To: Zach Curtis; [EMAIL PROTECTED]
>Subject: Re: [PHP-DB] # of Records in Table
> > What syntax can I use to determine how many records are in a MySQL table
> > then retrieve the value of the field "password" for the last record? I
> > using some combinations of COUNT(*) and LIMIT with no success.
>SELECT COUNT(*) will answer the first part. What did you try that lacked
>How do you define "last record"? We might need to see the table definition
>to answer this.
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to