change value in table depending on values in other table 
Author Message
 change value in table depending on values in other table

Hello,
I have to change values in one table depending on values
in other table.
For example (algorithm):
if Table1.AAA='A' then Table2.f5='1'
if Table1.BBB='B' then Table2.f5='2'

relation can be set between these two tables' 4 fields
f1,f2,f3,f4.

Please, how to write that in code...

Thanx,
Heidi



Mon, 19 Dec 2005 19:41:43 GMT  
 change value in table depending on values in other table
it's ok. I solved it with update
Quote:
>-----Original Message-----
>Hello,
>I have to change values in one table depending on values
>in other table.
>For example (algorithm):
>if Table1.AAA='A' then Table2.f5='1'
>if Table1.BBB='B' then Table2.f5='2'

>relation can be set between these two tables' 4 fields
>f1,f2,f3,f4.

>Please, how to write that in code...

>Thanx,
>Heidi
>.



Mon, 19 Dec 2005 20:15:15 GMT  
 change value in table depending on values in other table
seems i solved it, but it takes very long time to update
all records. Maybe there's a faster way?
Quote:
>-----Original Message-----
>Hello,
>I have to change values in one table depending on values
>in other table.
>For example (algorithm):
>if Table1.AAA='A' then Table2.f5='1'
>if Table1.BBB='B' then Table2.f5='2'

>relation can be set between these two tables' 4 fields
>f1,f2,f3,f4.

>Please, how to write that in code...

>Thanx,
>Heidi
>.



Mon, 19 Dec 2005 20:17:57 GMT  
 change value in table depending on values in other table
Hi Heidi,

Whether there's a faster way depends on your code and indexes. Please post
your code and describe the indexes on both tables.

--
Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP


Quote:
> seems i solved it, but it takes very long time to update
> all records. Maybe there's a faster way?
> >-----Original Message-----
> >Hello,
> >I have to change values in one table depending on values
> >in other table.
> >For example (algorithm):
> >if Table1.AAA='A' then Table2.f5='1'
> >if Table1.BBB='B' then Table2.f5='2'

> >relation can be set between these two tables' 4 fields
> >f1,f2,f3,f4.

> >Please, how to write that in code...

> >Thanx,
> >Heidi
> >.



Mon, 19 Dec 2005 22:19:38 GMT  
 change value in table depending on values in other table
Hi Heidi
UPDATE Table2 SET f5='1' WHERE EXISTS ;
 (SELECT * FROM Table1 WHERE Table1.f1=table2.f2 ;
 AND Table1.f3=Table2.f4 AND Table1.aaa='A')
UPDATE Table2 SET f5='2' WHERE EXISTS ;
 (SELECT * FROM Table1 WHERE Table1.f1=Table2.f2 ;
 AND Table1.f3=Table2.f4 AND Table1.bbb='B')

-Anders


Quote:
> Hello,
> I have to change values in one table depending on values
> in other table.
> For example (algorithm):
> if Table1.AAA='A' then Table2.f5='1'
> if Table1.BBB='B' then Table2.f5='2'

> relation can be set between these two tables' 4 fields
> f1,f2,f3,f4.

> Please, how to write that in code...

> Thanx,
> Heidi



Tue, 20 Dec 2005 07:47:36 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. update values in table A from values in table B

2. grid.txt.values VS. table.values

3. Field value in table changes mysteriously

4. Recalculating table with values from other table

5. Insert values from one table into another table.

6. Please help me update the values in one table with values from another table....

7. Summing values from 2 related tables in one SQL statement

8. insert dbf values into a table

9. saving RTF control value into SQL7 table

10. Add field to a new table based on Varibles values

11. VFP5.0a, Table Designer, Field Default Value

12. use directly value of table ?

 

 
Powered by phpBB® Forum Software