Home > database >  Pray god to help small white look at a problem
Pray god to help small white look at a problem

Time:10-03

There is a table in the oracle operations (t1) class (class) corresponding to the student id (stunum), another table (t2) enquiries (stunum) corresponding to the name (name), how to synthesize a table (t3) class (class) corresponding to the name list (name)?

CodePudding user response:

List the complete table structure, and the result you want;

CodePudding user response:

The create table t3
As
Select a t1 class, t2. Name the from t1, t2 where t1. Student id=t2. Student id

CodePudding user response:

Because the table structure didn't explain clearly, only according to the logic inference table structure, if the student number are arranged according to the class as follows: table t1 field class and student number is a many-to-many relationship, eg. Class 1 corresponding student number 1, 2, 3... Student number 1 also can appear in class 1, class 2, class 3... Table only two columns, and many-to-many relationships between columns, then the t1 table primary key is (class, stunum), table fields of t2 is a one-to-many relationship between the name and student id, temporary not consider condition of the same name, student number 1 in the first class is zhang SAN, student number 1 in another class is li si, zhang SAN and li si are corresponding student number 1, t2 table primary key should be name (name), but in order to get a class corresponding to the name of a relational table, must be in the third column table t2 introduced student id, because even know li si corresponding student number is 1, but I don't know which class, li si in more than one class has a student number 1, and if that is the problem of the t3, there is no need to create, t2 directly on the table there is a corresponding relationship, so back to the problem, question the main should be assuming that the student number are arranged according to the grade, a student number in more than one class is the only, the table t1 and t2 their structures have been individually, the second floor of this kind of circumstance to give the answer, my answer is burke at first!

CodePudding user response:

refer to the second floor sych888 response:
create table t3
As
The select t1 class, t2. Name the from t1, t2 where t1. Student id=t2. Student id

good

CodePudding user response:

reference 1st floor selling fruit net reply:
list complete table structure, and the result you want;

Through the above two tables, and want to get this table below so...

CodePudding user response:

reference Penho reply: 3/f
because of table structure didn't explain clearly, only according to the logic inference table structure, if the student number are arranged according to the class as follows: table t1 fields of the class and student number is a many-to-many relationship, eg. Class 1 corresponding student number 1, 2, 3... Student number 1 also can appear in class 1, class 2, class 3... Table only two columns, and many-to-many relationships between columns, then the t1 table primary key is (class, stunum), table fields of t2 is a one-to-many relationship between the name and student id, temporary not consider condition of the same name, student number 1 in the first class is zhang SAN, student number 1 in another class is li si, zhang SAN and li si are corresponding student number 1, t2 table primary key should be name (name), but in order to get a class corresponding to the name of a relational table, must be in the third column table t2 introduced student id, because even know li si corresponding student number is 1, but I don't know which class, li si in more than one class has a student number 1, and if that is the problem of the t3, there is no need to create, t2 directly on the table there is a corresponding relationship, so back to the problem, question the main should be assuming that the student number are arranged according to the grade, a student number in more than one class is the only, the table t1 and t2 their structures have been individually, the second floor of this kind of circumstance to give the answer, my answer is burke at first!

Thank you, table structure is as follows: through the above two tables, want to get this table below so...

CodePudding user response:

refer to the second floor sych888 response:
create table t3
As
Select t1 class, t2. Name the from t1, t2 where t1. Student id=t2. Student id
  • Related