LAST_INSERT_ID & LAST_UPDATE_ID

LAST_INSERT_ID & LAST_UPDATE_ID

am 24.05.2007 23:26:42 von sam rumaizan

--0-2038340943-1180042002=:49281
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

How can I select (retrieve) the last updated cell (field). Basically I need to pull the new information only.

I'm using for updating my database:

UPDATE table SET column = CONCAT_WS ('column,'" . $column."') WHERE column= value;

I need to select data:

SELECT * FROM table WHERE column=Whatever

I found LAST_INSERT_ID but i doesn't work



Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.http://us.rd.yahoo.com/evt=48518/*http://autos.yahoo.co m/carfinder/;_ylc=X3oDMTE3NWsyMDd2BF9TAzk3MTA3MDc2BHNlYwNtYW lsdGFncwRzbGsDY2FyLWZpbmRlcg-- hot CTA = Yahoo! Autos new Car Finder tool
--0-2038340943-1180042002=:49281--

Re: LAST_INSERT_ID & LAST_UPDATE_ID

am 24.05.2007 23:47:48 von PAUL MENARD

--0-944956495-1180043268=:91212
Content-Type: text/plain; charset=ascii

Well what database? If mysql you can use the php function mysql_insert_id();
http://www.php.net/manual/en/function.mysql-insert-id.php

----- Original Message ----
From: sam rumaizan
To: php-windows@lists.php.net
Sent: Thursday, May 24, 2007 4:26:42 PM
Subject: [PHP-WIN] LAST_INSERT_ID & LAST_UPDATE_ID

How can I select (retrieve) the last updated cell (field). Basically I need to pull the new information only.

I'm using for updating my database:

UPDATE table SET column = CONCAT_WS ('column,'" . $column."') WHERE column= value;

I need to select data:

SELECT * FROM table WHERE column=Whatever

I found LAST_INSERT_ID but i doesn't work



Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.http://us.rd.yahoo.com/evt=48518/*http://autos.yahoo.co m/carfinder/;_ylc=X3oDMTE3NWsyMDd2BF9TAzk3MTA3MDc2BHNlYwNtYW lsdGFncwRzbGsDY2FyLWZpbmRlcg-- hot CTA = Yahoo! Autos new Car Finder tool




--0-944956495-1180043268=:91212--

Re: LAST_INSERT_ID & LAST_UPDATE_ID

am 24.05.2007 23:52:41 von Stut

sam rumaizan wrote:
> How can I select (retrieve) the last updated cell (field). Basically I need to pull the new information only.
>
> I'm using for updating my database:
>
> UPDATE table SET column = CONCAT_WS ('column,'" . $column."') WHERE column= value;
>
> I need to select data:
>
> SELECT * FROM table WHERE column=Whatever
>
> I found LAST_INSERT_ID but i doesn't work

LAST_INSERT_ID will not work because you're not inserting anything. The
clue, you see, is in the name.

Your best bet would be to add a timestamp/datetime field to the table
and include that in the update. Then you can use that field to get the
last row that was changed.

-Stut

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: LAST_INSERT_ID & LAST_UPDATE_ID

am 25.05.2007 09:36:36 von sam rumaizan

--0-441287181-1180078596=:21045
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit


What I want to do is:

1-user has 10 columns (fields).
2- User updated one of these fields using CONCAT_WS(adding new data to previous data).
3- When user views any of his information he sees only the last updated part of the data.


So, timestamp/datetime field is not going to work.




Stut wrote:
sam rumaizan wrote:
> How can I select (retrieve) the last updated cell (field). Basically I need to pull the new information only.
>
> I'm using for updating my database:
>
> UPDATE table SET column = CONCAT_WS ('column,'" . $column."') WHERE column= value;
>
> I need to select data:
>
> SELECT * FROM table WHERE column=Whatever
>
> I found LAST_INSERT_ID but i doesn't work

LAST_INSERT_ID will not work because you're not inserting anything. The
clue, you see, is in the name.

Your best bet would be to add a timestamp/datetime field to the table
and include that in the update. Then you can use that field to get the
last row that was changed.

-Stut

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






---------------------------------
Be a better Heartthrob. Get better relationship answers from someone who knows.
Yahoo! Answers - Check it out.
--0-441287181-1180078596=:21045--

Re: LAST_INSERT_ID & LAST_UPDATE_ID

am 25.05.2007 10:09:31 von Lester Caine

sam rumaizan wrote:
> What I want to do is:
>
> 1-user has 10 columns (fields).
> 2- User updated one of these fields using CONCAT_WS(adding new data to previous data).
> 3- When user views any of his information he sees only the last updated part of the data.

Not sure what you are trying to do here.
Once you have updated the record
UPDATE table SET column = CONCAT_WS ('column,'" . $column."')
WHERE column= value;
Then the record 'column= value' will be updated.

SELECT * FROM table WHERE column=VALUE
will return that record - except you seem to be changing the 'key' by which
you reference the record?

So you probably need
SELECT * FROM table WHERE column = CONCAT_WS ('column,'" . $column."') to get
that record.

The NORMAL method of working would be
UPDATE table SET column = CONCAT_WS ('column,'" . $column."')
WHERE KEY_COLUMN = value;

Then
SELECT * FROM table WHERE KEY_COLUMN = value;
will return the whole record that was updated.
If you want to see the changes, then you would need to do this before and
after the update and compare the fields.

--
Lester Caine - G8HFL
-----------------------------
Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://home.lsces.co.uk
MEDW - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/
Firebird Foundation Inc. - http://www.firebirdsql.org/index.php

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: LAST_INSERT_ID & LAST_UPDATE_ID

am 25.05.2007 12:38:51 von Stut

sam rumaizan wrote:
> What I want to do is:
>
> 1-user has 10 columns (fields).
> 2- User updated one of these fields using CONCAT_WS(adding new data to
> previous data).
> 3- When user views any of his information he sees only the last updated
> part of the data.
>
>
> So, timestamp/datetime field is not going to work.

Indeed not, in fact what you need to do is add another table. Those 10
columns should be in a separate table. With a timestamp. Each bit of
added data should create a row in that table. Then you can get the last
bit of data added to each field for each user.

This is called database normalisation, and I suggest you look it up on
Wikipedia or Google.

-Stut

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: LAST_INSERT_ID & LAST_UPDATE_ID

am 25.05.2007 22:53:20 von Stut

sam rumaizan wrote:
> You mean Normalization

Not in my part of the world. England. You know, where English came from.

And quit with the bold!! It's not big, it's not clever and it puts *'s
all over your email!

-Stut

> */Stut /* wrote:
>
> sam rumaizan wrote:
> > What I want to do is:
> >
> > 1-user has 10 columns (fields).
> > 2- User updated one of these fields using CONCAT_WS(adding new
> data to
> > previous data).
> > 3- When user views any of his information he sees only the last
> updated
> > part of the data.
> >
> >
> > So, timestamp/datetime field is not going to work.
>
> Indeed not, in fact what you need to do is add another table. Those 10
> columns should be in a separate table. With a timestamp. Each bit of
> added data should create a row in that table. Then you can get the last
> bit of data added to each field for each user.
>
> This is called database normalisation, and I suggest you look it up on
> Wikipedia or Google.
>
> -Stut
>
>
>
>
> ------------------------------------------------------------ ------------
> Ready for the edge of your seat? Check out tonight's top picks
> on Yahoo! TV.

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php