I have two tables A and B
in table B i have only one object and Two columns X and Y,
I update its values daily by a timer from an external host
now i want to create a generated column and make an expression to
get the value from column “X” from table B and divide it by each value from table A no matter how many object created in table A.
the question is how to write an expression like this?
i tried to write B.X / value but its not working
We are considering your question, give us a little time.
You are not able to create generated column with relations. In the generated column you can use only columns from the table you are creating a column in.
In my opinion it is not possible to do by one call. So my suggestion is the following:
- Get all data from
A and create a factor
var f = 1 / A1 / A2 / ... / An
- Then get data with selected property
valueB*<f> as valueWithFactor for example
0.5 then use the fallowing select
Just double checking on this since it’s been a couple years. Is it still not possible to write an expression in a column from table A based off of data from table B?
I also have a similar instance where this would be great but if it’s still not possible to do in one SQL expression then I have a workaround option in mind that uses API calls from the UI.
It is not possible to create a generated column in a table based on a value from another table. The closest solution would be creating a database View. That approach allows you to combine multiple columns from related tables in one virtual (read-only) table.
Thank you Mark, that is helpful.