locked
Foreign Keys RRS feed

  • Question

  • User-1397778012 posted

    Hi there,

    I am not sure if I have this in the right section so please don't yell at me if I don't. I have two tables that are linked together with a foreign key and I am going to use a gridview to display certain things from table A, but table A contains a foreign key INT to table B. I want to be able to display instead of the int, an actual element from that foreign key's row. What is the best way to do this? I am sort of new to this kind of thing. I would appreciate any help I can get.

    Friday, August 14, 2009 4:23 PM

Answers

  • User-1360095595 posted

    Yell yell yell!  :-)

    What you will need to do is write a select statement where you do an INNER JOIN (or a LEFT OUTER JOIN depending on what you want) on the two tables using the key/primary key, so you can extract/use the text that you want from table B.  Let me know if you need more details.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 14, 2009 4:51 PM
  • User1512755243 posted

     Hi

      You have to build ur select query by joining the two tables and getting all the required columns and then u can populate those results to a dataset in ur code. Then u can use this dataset as datasource to ur grid.

      So basically ur query has to be modified to get all required columns frm two tables. I guess thats all u need to do. Let me know if I got u wrong.

     

    Thnx,

    Kumar Pindiprolu.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 14, 2009 4:54 PM

All replies

  • User-1360095595 posted

    Yell yell yell!  :-)

    What you will need to do is write a select statement where you do an INNER JOIN (or a LEFT OUTER JOIN depending on what you want) on the two tables using the key/primary key, so you can extract/use the text that you want from table B.  Let me know if you need more details.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 14, 2009 4:51 PM
  • User1512755243 posted

     Hi

      You have to build ur select query by joining the two tables and getting all the required columns and then u can populate those results to a dataset in ur code. Then u can use this dataset as datasource to ur grid.

      So basically ur query has to be modified to get all required columns frm two tables. I guess thats all u need to do. Let me know if I got u wrong.

     

    Thnx,

    Kumar Pindiprolu.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 14, 2009 4:54 PM