Updating field from one table to another sql
But what if you want to compare the value of a model field with another field on the same model?Django provides act as a reference to a model field within a query.
If the related models haven’t been imported yet, Django keeps tracks of the relationships and adds them when the related models eventually are imported.
I have one table A has column (id, field_1,field_2), and another table B has column (id,field_2) Now I want to merge table B to A, that means i want to update field_2 in table A to value of table B. BTW I am using oracle Thanks Now, each time the above is executed, it will do it across all rows in the table.
If this is something you need to do all the time, I would suggest something else, but for a one-off or very small tables it should be sufficient.
But how is this possible, given that a model class doesn’t know which other model classes are related to it until those other model classes are loaded?
The answer lies in the module inside each application.
These references can then be used in query filters to compare the values of two different fields on the same model instance.