calculate field

154
2
05-05-2021 02:32 AM
Labels (1)
MohammedElsayed
New Contributor II

is there a way to calculate a field in a table from data in another table in SQL database?

the case is I have two tables in a database both have the same IDs, so I want to fill a column in one table from the a column in the other table.

i tried to write a code but it did not work as I'm still a beginner in coding.

if Charts_Limits['SURVEY_ID_REF'] == Survey_Limit_Polygon['SURVEY_ID_REF']:

    Charts_Limits['Survey_Type_Updated'].append(Survey_Limit_Polygon['Survey_Type_Updated'])

0 Kudos
2 Replies
DanPatterson
MVP Honored Contributor

Temporarily join the tables and calculate your field in the target table using the field in the join table.  When done, remove the join.

As a note, if you are trying to update values in the target table, you can always make a query/selection prior to doing the calculation.  Field calculations are only done on selected records


... sort of retired...
0 Kudos
RobertBorchert
Frequent Contributor II

Can you put the two features into a relationship?

This SQL code works in a definition query for features in a relationship.

Table1                                          Table2                                      Table2                                   Table2

ORIGINFIELD IN (SELECT DESTINATIONFIELD FROM <RELATED NAME> where <FIELDNAME> <QUERY>)

I use it to show only points in a Dashboard that have an attachment associated with it.  It may work with a SQL query for Labels.

0 Kudos