Re: SELECT?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

        As there are only 500 rows, there is not any harm in fetching all
records through one query and then do the update between while loop


$query="select * from table";
$result=mysql_query($query);

while($row=mysql_fetch_array($result))
{
$newquery="update YOUR STATEMENT where uniquefield like
$row['uniquefield']";
mysql_query($newquery);
}


if you really need to fetch only one record at a time, you can use the LIMIT
keyword in your SQL statement, and can create the script as needed.


Zareef Ahmed

----- Original Message ----- 
From: "Christian Ista" <ml@xxxxxxxx>
To: "'William Stokes'" <kalles@xxxxxxxxxxxxx>; <php-general@xxxxxxxxxxxxx>
Sent: Wednesday, December 28, 2005 3:57 AM
Subject: RE:  SELECT?


> > From: William Stokes [mailto:kalles@xxxxxxxxxxxxx]
> > I have one MySQL table with about 500 rows. I need to read the table one
> > row at a time, make some changes to data in one field and then store the
> > changed data to another table.
>
> 1. May be add a column, CHANGED_FL with default value N.
> 2. Select to find the ID minimum with a select CHANGED_FL is N
> 3. Select the row with the ID found above and make you business
> 4. Make change and change CHANGED_FL to Y
>
> Repeat operation 2 to 4
>
> C.
>


====================================================
PHP Expert Consultancy in Development  http://www.indiaphp.com
Yahoo! : consultant_php MSN : consultancy@xxxxxxxxxxxx

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

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux