Re: temp tables mysql OT
| From: | Daniel Brown | Date: | Thu, 13 Dec 2007 15:38:59 +0000 |
| Subject: | Re: temp tables mysql OT | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265840@lists.php.net to get a copy of this message | ||
On Dec 13, 2007 10:37 AM, Daniel Brown <parasane@gmail.com> wrote:
> <?
> // Put DB and config includes here.
>
> $sql = "SELECT * FROM prod_table WHERE product_name != '' ORDER BY
> product_id";
> $result = mysql_query($sql) or die(mysql_error());
> while($row = mysql_fetch_array($result)) {
> $ssql = "INSERT INTO tmp_table(product_id,product_name,val,val2) ";
> $ssql .=
> "VALUES('".$row['product_id']."','".$row['product_name']."','$row['val']."','".$row['val2']."')";
> mysql_query($ssql);
> }
>
> mysql_query("DROP TABLE prod_table");
> mysql_query("RENAME TABLE tmp_table TO prod_table") or die(mysql_error());
> ?>
There are much prettier, cleaner, more efficient ways of doing it,
I'm sure, but if you're banging your head off the wall just vying for
a simple solution, MySQL can handle the ~5,001 queries without issue.
;-)
--
Daniel P. Brown
[Phone Numbers Go Here!]
[They're Hidden From View!]
If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.