Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 505877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:38:37+00:00 2026-05-13T06:38:37+00:00

I have 4 tables: CustomerDocument, CustomerLink, CustomerAdditionalInfo, and CustomerImage. They each have a value

  • 0

I have 4 tables: CustomerDocument, CustomerLink, CustomerAdditionalInfo, and CustomerImage. They each have a value of CustomerNumber, and I need to way to pull the customer numbers from each table and put in a drop down list. I know how to do it with one table, but not multiple. Also, there is a restriction that the CustomerNumber needs to be not null, so do I need to include this with each join? Here is a bit of code I have now. oDb is the DataContext

var oData = from c in oDb.CustomerAdditionalInfos
                    where ( c.CustomerID == CustomerID && 
                            c.CustomerNumber != null   && 
                            c.CategoryID == CategoryID )

                    orderby c.CustomerNumber
                    select new { c.CustomerNumber };

        return oData;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:38:37+00:00Added an answer on May 13, 2026 at 6:38 am

    You could do this….

    var oData = (from c in oDb.CustomerAdditionalInfos
                 where c.CustomerNumber != null
                 select new 
                 {
                      CustomerNumber = c.CustomerNumber
                 }).Union
                     (from d in oDb.CustomerDocument
                      where d.CustomerNumber != null
                      select new
                      {
                          CustomerNumber = d.CustomerNumber
                      }).Union
                          (from l in oDb.CustomerLink
                           where l.CustomerNumber != null
                           select new
                           {
                               CustomerNumber = l.CustomerNumber
                           }).Union
                                (from i in oDb.CustomerImage
                                 where i.CustomerNumber != null
                                 select new
                                 {
                                     CustomerNumber = i.CustomerNumber
                                 }).OrderBy(c => c.CustomerNumber);
    

    That is simply a union of all of the CustomerNumbers in all four tables. This WILL include duplicates if there are duplicates. If you want only distinct CustomerNumbers, then just do a Distinct() after the OrderBy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assuming we have tables Order(customerId,orderDetails...) Customer(Id, customerDetails...) What is the easiest way to query
I have tables like: 'profile_values' userID | fid | value -------+---------+------- 1 | 3
I have tables like tbl_biodata: id : int value=>1 name : varchar(50) value =>
I have tables with listings, categories and one that maps them to each other.
I have tables contracts and users and i need to show contracts sorted by
I have tables of data samples, with a timestamp and some data. Each table
I have tables like this fake ones: data: id type month value 1 1
i have tables driver, cars and trailers they are all in relationship. and main
I have tables like Customer , Purchase etc which sometimes have associated documents with
If I have tables in doctrine for user_1, user_2, etc. is there a way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.