Re: Update Statement
| From: | Ng Hwee Hwee | Date: | Thu, 19 Feb 2004 01:08:02 +0000 |
| Subject: | Re: Update Statement | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-33015@lists.php.net to get a copy of this message | ||
hi,
thank you for your reply but I can't do a multiple table update because my
server is using MySQL with version lesser than 4.0... please enlighten me
how I can write the same update statement without using multiple table
update.. is there a way to use JOIN or something??
thanks thanks..
hwee
----- Original Message -----
From: "Ricardo Lopes" <lopes@elevaconsult.pt>
To: "Ng Hwee Hwee" <hhwee@towa.com.sg>
Cc: "PHP DB" <php-db@lists.php.net>
Sent: Wednesday, February 18, 2004 5:41 PM
Subject: Re: [PHP-DB] Update Statement
> you could use:
>
> for ($i=0; $i< max; $i++)
> {
> mysql_query("update Table1, Table2 set Table1.field1 = Table2.field2
> where Table1.no = Table2.no");
> }
>
>
> OR if you use mysqlt daemon (support for transactions, in this case is
best)
>
> mysql_query('BEGIN');
> for ($i=0; $i< max; $i++)
> {
> if (! mysql_query("update Table1, Table2 set Table1.field1 =
> Table2.field2 where Table1.no = Table2.no"))
> {
> mysql_query('ROLLBACK');
> die('ERROR - in query nº: '.$i);
> }
> }
> mysql_query(COMMIT');
>
>
> Execute all or not execute none. I personally use adodb to connect to
> databases and control transactions.
>
> If what you really want is to execute then all in just one function call
to
> the database, i don't know how can you do it with your mysql version.
>
> HTH
>
> ----- Original Message -----
> From: "Ng Hwee Hwee" <hhwee@towa.com.sg>
> To: "DBList" <php-db@lists.php.net>
> Sent: Wednesday, February 18, 2004 2:14 AM
> Subject: [PHP-DB] Update Statement
>
>
> hi all,
>
> I would like to do the following:
>
> update Table1, Table2 set Table1.field1 = Table2.field2 where Table1.no =
> Table2.no
>
> however, i found that multiple updates can only work for MySQL version
4.0.4
> but mine is 3.23.54... can anyone enlighten me on how I can achieve the
same
> results with this older MySQL version? or can PHP 4.2.2 help me in any
way?
>
> Thank you so much!
>
> Hwee
>