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

  • Home
  • SEARCH
  • 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 3488786
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:18:49+00:00 2026-05-18T11:18:49+00:00

Assume that we’ve three tables Course – table —————— ID | CourseName —————— 1

  • 0

Assume that we’ve three tables

Course – table

------------------
 ID | CourseName
------------------
 1  |  C++
 2  |  Java
------------------

Teacher – table

-----------------------
 ID |   TeacherName
-----------------------
 1  |   Professor 1
 2  |   Professor 2  
-----------------------

CourseTeacher – table

----------------------------
 ID | CourseID | TeacherID 
----------------------------
 1  |   1      |     1   
 2  |   1      |     2    
 3  |   2      |     1   
 4  |   2      |     2     
----------------------------

Now that’s what to do as AFAK, but how to select, insert, update, delete records in such a format!

I mean, I’d use a simple “INSERT INTO … VALUES (..,..,..)” or a simple “SELECT * FROM …”

but now to retrieve the same single information I’ve to use some queries that includes the 3 tables somehow (Hint: I already use joins, but still how!!)

A select and insert SQL statement for my case would be very helpful.

I don’t use any models and this complicated stuff, I don’t know what the use of such a thing!
I’m using SQL Queries in my ADO.NET Objects and everything is working fine so far!

  • 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-18T11:18:50+00:00Added an answer on May 18, 2026 at 11:18 am

    I’m not sure to understand what your question is …

    Let’s assume that your PK in each table is automatically incremented.

    To add a course : INSERT INTO Course VALUES 'My New Course'
    To add a teacher : INSERT INTO Teacher VALUES 'My New Teacher'

    Tu add an existing Course to an existing Teacher :
    In the worst case scenario, meaning that you only know the names of the Teacher and the Course

    SELECT ID FROM Teacher WHERE NAME = 'My New Teacher' -> id1
    SELECT ID FROM Course WHERE NAME = 'My New Course' -> id2
    INSERT INTO CourseTeacher(IDCOURSE,IDTEACHER) VALUES (id2,id1)
    

    In fact, in your application, when your user selects a Course to add to a Teacher, you should already know what the IDs are, because when you got the list containing them, you certainly have done this :

    SELECT ID, NAME FROM Teacher
    SELECT ID, NAME FROM Course.
    

    A link which may be useful if what I wrote is not :
    http://www.singingeels.com/Articles/Understanding_SQL_Many_to_Many_Relationships.aspx

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

Sidebar

Related Questions

Assume that I have one big table with three columns: user_name, user_property, value_of_property. Lat's
Assume that the default ordering of a MySQL-table (ISAM) is changed by executing: ALTER
Assume that there is a 'Employee' table with salary as one of the columns.
Assume that I have a table user_count defined as follows: id primary key, auto
Assume that we have N erlang nodes, running same application. I want to share
Assume that you have a running SQL Server Express instance named (local)\SQLEXPRESS. Its database
Assume that the core project has a base entity and every plugin maybe extends
I assume that you can't use a JavaScript code snippet to validate if the
I assume that char* = string is the same to char* = new char[6]
I assume that most of the analyzing and tracking is done based on the

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.