BMK BMK - 2 months ago 5
SQL Question

How to get attribute from foreign key

If I have a foreign key how do I get an attribute from the data object?

For example I want to have data objects that gives me the id for 'a', but I then want to get the name from 'a' and not just the referenced id?

Such as select a_ID from rTable - this gives me the id of the object, but how do I then get the name attribute from that reference id?

Answer

use inner join for Example

select Table1.name ,Table2.name from Table1 inner join Table2 on Table1.FK==Table2.ID

Check this link SQL - INNER JOINS

Comments