# Selecting from other tables with information from the main table

**URL:** <https://forum.kirupa.com/t/selecting-from-other-tables-with-information-from-the-main-table/279034>\
**Category:** Uncategorized\
**Created:** [January 8, 2009, 6:51pm UTC](https://forum.kirupa.com/t/selecting-from-other-tables-with-information-from-the-main-table/279034 "2009-01-08T18:51:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr\_white](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@mr\_white](https://forum.kirupa.com/u/mr_white)\
**Post date:** [January 8, 2009, 6:51pm UTC](https://forum.kirupa.com/t/selecting-from-other-tables-with-information-from-the-main-table/279034/1 "2009-01-08T18:51:13Z")

</div>

Hello,

I’m making a phone book application in **[ASP.NET](http://ASP.NET)**. I store general information of people such as name etc on one table called “ **people** ”, and I’ve another table called “ **relatedInformation** ” which has 5 columns (ID, Name, Info, PersonID, Type). In this table I store all other information regarding people, because a person might have more than one address, phone number or email.

So let’s say I got one row data from \*\*People \*\*table with **SqlDataReader** , and print the “Name” value on the screen.

Now what I want is, I want to do another query to “ **relatedInformation** ” table, select data where Type is 1 (phone numbers), and PersonID is the ID from “People” table. so I can list all phone numbers.

Then another query but this time select the ones where Type is 2 (addresses, for example.)

what is the logic behind doing this with C# and [ASP.NET](http://ASP.NET) ?

if I create data command and then a data reader and stuff for each one of these things, code becomes really heavy.  
In old ASP it only took 2 lines of code to do this with using **RecordSet**.

Can you please explain me the logic of doing this and, if possible help me with some code?  
And if i couldn’t make my self clear, please ask me so I can explain more clearly.

Thank you very much.
