How to Select Multiple Records from Multiple Tables at Once - SQL Server/C#/.NET/T-SQL

Posted by peace on Stack Overflow See other posts from Stack Overflow or by peace
Published on 2010-05-22T22:52:43Z Indexed on 2010/05/22 23:00 UTC
Read the original article Hit count: 257

Filed under:
|
|
|
|

I have two tables Customer and CustomerPhone. Customer usually has multiple phone numbers, so when i run select statement on customer 101, i will get multiple records due to the multiple phone numbers.

alt text

As you see below all the "Phone" and "Fax" field belongs to CustomerPhone table. These are considered as two records in the CustomerPhone table whereas the rest of fields relate to Customer table which is a single record.

What should i do to fill Phone and Fax field in this case? Should i run select statement on CustomerPhone first and then run select statement on Customer?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET