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 73457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:12:16+00:00 2026-05-10T20:12:16+00:00

DDL for Database Tables: Users: id – int – identity name – varchar –

  • 0

DDL for Database Tables:

    Users:     id - int - identity     name - varchar - unique      PCs:     id - int - idnetity     name - varchar - unique     userid - FK to Users      Apps:     id - int - identity     name - varchar     pcid - FK to PCs 

I created a DataContext using the Linq To SQL designer in Visual Studio 2008.

I want to perform this query:

select   users.name,   pcs.name,   apps.name from   users u   join pcs p on p.userid = u.id   join apps a on a.pcid = p.id 

I was told in another thread where I posted an answer that the following was incorrect and that it created a cross-join.

var query = from u in db.Users // gets all users         from p in u.PCs // gets all pcs for user         from a in p.Apps // gets all apps for pc         select new         {             username = u.Name,             pcname = p.Name,             appname = a.Name         }; 

When I execute this query I get the correct results. A cross-join with two records in each table should return 8 records but my query correctly returns the two records.

Am I lucky, or is the person telling me that I’m wrong confused?

  • 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. 2026-05-10T20:12:17+00:00Added an answer on May 10, 2026 at 8:12 pm

    That will work. It’s normal because the second ‘from’ inquires in the PC’s set of the users and the third ‘from’, the Apps set of the pcs. And I guess that is not going generate a cross join as T-Sql, because the conditions are already defined in the foreign keys and associations.

    But I guess this should be the syntactically you want by inner join;

    var query = from u in db.Users             join p in db.PCs on p.UserId == u.Id             join a in db.Apps on a.PCId == p.Id             select new             {                 username = u.Name,                 pcname = p.Name,                 appname = a.Name             }; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 67k
  • Answers 67k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I tried Miles' excellent suggestion above, but unfortunately it doesn't… May 11, 2026 at 11:46 am
  • added an answer You could have a look at the WEBSOM project. Even… May 11, 2026 at 11:46 am
  • added an answer Try HTML::Parser: #!/usr/bin/perl use strict; use warnings; use HTML::Parser; my… May 11, 2026 at 11:46 am

Related Questions

DDL for Database Tables: Users: id - int - identity name - varchar -
I encountered the following ddl in a pl/sql script this morning: create index genuser.idx$$_0bdd0011
I am looking into using only a ddl to run my query, not a
Is there any easy way to retrieve table creation DDL from Microsoft Access (2007)
Does anyone know of a reasonably priced tool that will create DDL statements to
Exception: Failed to compare two elements in the array. private void assignNames(DropDownList ddl, Hashtable
I have a Default.aspx that redirects to a Page1.aspx. My ddl is loaded and
List<String> nameList = new List<String>(); DropDownList ddl = new DropDownList(); List is populated here,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.