+ 1
Foreign key referencing
Please a table has a foreign key but I need to use a different column in that table For calculation in another table as a column its own please how do I go about it Hope the question is understood
4 ответов
+ 2
No, the foreign key column from the second table does not have to be used in the calculation. Here is a sample of what I think your query might look like:
SELECT (tbl1.col3*tbl2.col3) AS NewCol FROM tbl1 LEFT JOIN tbl2 ON tbl2.col2 = tbl1.col4;
+ 4
Before I answer, let me reflect what I understand: you have two tables joined on a foreign key. You wish to use a field from the first table and a field from the second table to perform a calculation, and assign a new column name to the result. Is this accurate?
+ 1
First I need to reference a column in another table but the column I need to reference is not a primary key and I am required to use that column for calculation in the referenced table.
Please do you understand the question now?
+ 1
Thanks