![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
comp.lang.php archiveMultiple update question
From: Epetruk <nobody@blackhole.com>
Date: Mon Oct 31 2005 - 00:29:09 CET
Hi,
I have a mySql question here on updates to multiple tables.
Here's a simple schema to clarify things:
Structure
Table A
Table B
Data
Table A
Table B
Now it is possible to group the rows in Table B in to sets where each set
B1 group with B1 field value of 1
B1 group with B1 field value of 2
I would like field A2 in Table A updated with a value that is obtained as
The query gets the value of the A1 field for the row whose A2 value it is to
It looks at the B1 groups to see which group has the same B1 field value as
It then gets the highest value for B2 for all the records in that B1 group;
It updates field A2 with this value.
For example, to update Row 1, the query will get the value of the field A1
It will then look at the B1 groups to see which group has the same B1 field
It will then look at all the B2 field values in this group, and see what the
Lastly, it will update the field A2 in row 1 with this value of 3.
I hope this explains what I'm trying to achieve - sorry if it's a bit
I had a query that ran something like this, but it didn't quite work:
UPDATE A INNER JOIN B
TIA,
-- Akin aknak at aksoto dot idps dot co dot ukReceived on Mon Nov 21 02:53:13 2005 |