mysql databases

mysql databases

am 14.10.2006 00:46:49 von bob plano

how would you add something new into a table and take out something
old? example:

(1) 1st something
(2) 2nd something
(3) 3rd something
(4) 4th something


and then you add in something new so then the table would look like

(1) new something
(2) 1st something
(3) 2nd something
(4) 3rd something


thanks in advance

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

Re: mysql databases

am 14.10.2006 00:52:40 von Niel Archer

Hi Bob

Your question isn't very clear. Do you want to remove the oldest entry,
newest, or is there some other criteria to diceide?

Niel

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

Re: mysql databases

am 14.10.2006 02:56:27 von Dave W

------=_Part_33675_17398125.1160787387118
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

He means that he wants to use REPLACE and take out the old entry and update
it with a new one. Although, you would probably use UPDATE instead.

--
Dave W

------=_Part_33675_17398125.1160787387118--

Re: mysql databases

am 14.10.2006 03:02:02 von Niel Archer

Hi

> He means that he wants to use REPLACE and take out the old entry and update
> it with a new one. Although, you would probably use UPDATE instead.

Hmmm... Thought this was DB list, not mind-readers.
I would also *guess* that would be the intention, but his example seems
to remove the newest entry, not the oldest, hence I stopped guessing and
asked.


Niel

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

Re: mysql databases

am 14.10.2006 19:47:38 von bob plano

sorry, i meant that i wanted to remove the oldest entry and put in a
new entry with UPDATE or INSERT.

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

Re: mysql databases

am 14.10.2006 20:18:34 von Niel Archer

Hi Bob

First you would need a means of identifying your oldest entry, some kind
of Date-Time field would seem simplest. Then, one way, would be to
SELECT the oldest value and use it in the 'where' clause of an UPDATE.


SELECT MIN(stamp) FROM table;
will get the oldest date-time value

and
UPDATE table SET stamp = '$NewStamp', col2 = $col2 WHERE stamp = '$Oldest;;
would update the entry.

Apologies for the sparse code snippets, but I'm in a hurry and don't
have time to write the full PHP for the queries.


Niel

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

Re: mysql databases

am 14.10.2006 23:19:58 von Bastien Koert

whynot keep all and just sort/limit them to get the data you want?

bastien


>From: "bob plano"
>To: php-db@lists.php.net
>Subject: Re: [PHP-DB] mysql databases
>Date: Sat, 14 Oct 2006 12:47:38 -0500
>
>sorry, i meant that i wanted to remove the oldest entry and put in a
>new entry with UPDATE or INSERT.
>
>--
>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