sql - Select from audit table -


i have following table

column1 column2 newvalue oldvalue 

in columns newvalue oldvalue values (foreign keys) other table. need display other column referenced table(i.e. based on primary keys). in select instead of newvalue key displayed column coresponds keys. new here, if want clarify question more, it. in advance.

edit: in first table columns entityid(from audited table), columnname, oldvalue, newvalue

second table addressid, city, street, zipcode.

in first table in colmns newvalue, oldvalue pks second table. need display example oldstreet, new street.

what need join tables together. there different types of join, case need use inner join, reason column newvalue , column oldvalue foreign keys. can join 2 tables following sample:

 select column1, column2,        b.newcolumn1, -- table b        c.newcolumn2,  -- table c tablea inner join tableb b    on a.newvalue = b.newvalue -- join on fk = pk inner join tablec c   on a.oldvalue = c.oldvalue  

you can google how use join here link


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -