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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:34:38+00:00 2026-05-22T14:34:38+00:00

I’m trying to join 3 tables in 1 SQL query but I’m really a

  • 0

I’m trying to join 3 tables in 1 SQL query but I’m really a ‘noob’ with the join query, this is what I’ve ‘created’ so far :

SELECT m.Mod_ID as Modelnr, m.Mod_Naam as Modelnaam, m.Mod_Omschrijving as Omschrijving, m.Taal_ID as Taal, m.User_ID as Ontwerper 
FROM Model as m 
INNER JOIN Login as l ON m.User_ID = l.User_ID 
INNER JOIN Taal as t ON m.Taal_ID = t.Taal_ID
WHERE m.User_ID = '" + userid + "' 

The DB was created inside Visual studio (asp.net c#), the Tables : Model, Taal and Login.

  • Model : Mod_ID, Mod_Naam, Mod_Omschrijving, Taal_ID, User_ID
  • Taal : Taal_ID, Taal
  • Login : User_ID, U_Naam, U_Achternaam

Tables & Relations : http://i52.tinypic.com/2upxmbk.jpg

Code behind to fill the gridview :

SqlCommand objCommand = new SqlCommand("SELECT m.Mod_ID as Modelnr, m.Mod_Naam as Modelnaam, m.Mod_Omschrijving as Omschrijving, m.Taal_ID as Taal, m.User_ID as Ontwerper from Model as m INNER JOIN Login as l ON m.User_ID = l.User_ID INNER JOIN Taal as t ON t.Taal_ID = t.Taal_ID WHERE m.User_ID = '" + userid + "' ", con);
dr = objCommand.ExecuteReader();
gvModel.DataSource = dr;
gvModel.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
gvModel.DataBind();

Trying to show Model in a gridview with the corresponding language from Taal (Taal.Taal) and user from Login (Login.U_Naam).

What I’m getting atm (only 3 rows in Model inside the DB) : http://i55.tinypic.com/2wbrcd2.jpg

But I’m still getting just number ID’s in my gridview.
Anyone who can help me out ?

thanks !

  • 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-22T14:34:39+00:00Added an answer on May 22, 2026 at 2:34 pm

    It looks to me like your query is doing exactly what it’s supposed to – the problem is in the “select” part of your query – everything is coming from the Model table.

    After you do the “from” and the joins, the data that you’re selecting looks like this:

    |         these columns come from the Model table          |                          these come from the User table                              |   Taal table   |
    | Mod_ID | Mod_Naam | Mod_Omschrijving | Taal_ID | User_ID | User_ID | Username | Password | U_Naam | U_Voornaam | U_Geboorte | U_Dienst | (....) | Taal_ID | Taal |
    

    …you can think of it kind of like “one big table”. So you want to select things from the User and Taal tables too – otherwise you made the database do all the work of joining them for nothing. I’m pretty sure that what you want is:

    SELECT m.Mod_ID as Modelnr, m.Mod_Naam as Modelnaam, m.Mod_Omschrijving as Omschrijving,
        t.Taal as Taal, l.U_Naam as Ontwerper -- <-- this is the only bit that's different
    FROM Model as m 
    INNER JOIN Login as l ON m.User_ID = l.User_ID 
    INNER JOIN Taal as t ON m.Taal_ID = t.Taal_ID
    WHERE m.User_ID = @user_ID
    

    I also fixed the SQL injection problem you have, to call this in .NET, do this:

    SqlCommand objCommand = new SqlCommand("SELECT .... etc", con);
    objCommand.Parameters.AddWithValue("@user_ID", userid);
    dr = objCommand.ExecuteReader();
    // as before
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into

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.