Re: Not quite relevant question about coding and query
| From: | Jacky@lilst | Date: | Fri, 19 Jan 2001 19:55:33 +0000 |
| Subject: | Re: Not quite relevant question about coding and query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-35581@lists.php.net to get a copy of this message | ||
So what i should really do is like this:
$anotherQuery = "select mysql_insert_id(UserID) from user";
$resultUserID = mysql_query($anotherQuery);
is that corerct?
Jack
jacky@activelifestyle.com
"There is nothing more rewarding than reaching the goal you set for
yourself"
----- Original Message -----
From: <php3@developersdesk.com>
To: Jacky@lilst <jacky@activelifestyle.com>; Jason Murray
<Jason.Murray@melbourneit.com.au>; <php-general@lists.php.net>
Sent: Friday, January 19, 2001 12:36 AM
Subject: Re: [PHP] Not quite relevant question about coding and query
> Addressed to: "Jacky@lilst" <jacky@activelifestyle.com>
> "Jason Murray" <Jason.Murray@melbourneit.com.au>
> <php-general@lists.php.net>
>
> ** Reply to note from "Jacky@lilst" <jacky@activelifestyle.com> Fri, 19
Jan 2001 13:15:13 -0600
>
> What happens when more than one person updates the tables at nearly
> the same time?
>
> a - insert record 9
>
> b - insert record 10
>
> a - get max ID = 10
>
> b - get max ID = 10
>
> Something doesn't look right here....
>
>
> What you are looking for is mysql-insert-id()
> Get the id generated from the previous INSERT operation
>
>
>
> http://www.php.net/manual/en/html/function.mysql-insert-id.html
>
>
>
> >
> > thanks for Jason:-) Lucky the ID is sequential. That was command I
> > was looking for. cheers Jack jacky@activelifestyle.com "There is
> > nothing more rewarding than reaching the goal you set for yourself"
> > ----- Original Message ----- From: Jason Murray
> > <Jason.Murray@melbourneit.com.au> To: 'Jacky@lilst'
> > <jacky@activelifestyle.com>; <php-general@lists.php.net> Sent:
> > Thursday, January 18, 2001 11:56 PM Subject: RE: [PHP] Not quite
> > relevant question about coding and query
> >
> >
> > > > $query = "insert into user values
> > >
> > > ('firstname','lastname','address','phone')";
> > > > $resultinsert = mysql_query($query);
> > > >
> > > > $getID = "select userID from user"; // Will this get me the
> > > > // Id of the record I just
inserted?
> > > > $resultID = mysql_query($getID);
> > >
> > > No, it won't - it'll return every userID in the table.
> > >
> > > If your userIDs are sequential, you can just select "MAX(userID)"
instead
> > > of userID.
>
>
> Rick Widmer
> Internet Marketing Specialists
> http://www.developersdesk.com
>