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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:12:12+00:00 2026-06-02T03:12:12+00:00

I have created ‘students’ table where ‘sid’ is the primary key and I have

  • 0

I have created ‘students’ table where ‘sid’ is the primary key and I have inserted many values into sid. I have created a second table called ‘courses’ and it has a primary key ‘cid’ I have entered values for cid as well. Now, I want to create a relation table called ‘enroll’ which I have done like-

create table enroll(
    grade char(2),
    sid int not null,
    cid int not null,
    primary key(sid,cid),
    foreign key (cid) references courses(cid) on delete cascade,
    foreign key (sid) references students(sid) on delete cascade
);

Now, when I try to view the table using select * from enroll;
I don’t get any output. It says “0 rows returned”. Why is this? Isn’t it supposed to have all the values of sid and cid from the other tables?

  • 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-06-02T03:12:14+00:00Added an answer on June 2, 2026 at 3:12 am

    In Order to create a new table from values in your other table you can do something like this:

    CREATE TABLE new_table AS (SELECT * FROM old_table);
    
    • The select statement will be the fields that will be pulled.
    • You can rename the columns like: Select [field name] as [what you want field name to be]

    For More information read this article

    Anyway for your particular case:

     Create table enroll AS (Select s.sid AS 'Sid', c.cid AS 'Cid' from courses c inner join students s on c.something = s.something)
    

    replace ‘.something’ with the id of the student

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

Sidebar

Related Questions

I have created a foreign key (in SQL Server) by: alter table company add
I have created a simple web service called TimeServerBean . It's working properly, the
I have created a SeedData class, and populated it with the values that I
I have created form using ModelForm but its not saving data into database. views.py
i have created a table in mysql to store polygon data: CREATE TABLE geom
I have created a new database table with the name 'table'. Now i'm trying
Have created a c++ implementation of the Hough transform for detecting lines in images.
I have created a facebook apps. Works fine for me. It contains canvas url,
I have created a mac application using the WebView. But issue is that webView
I have created a map application to show near by places on the map.When

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.