创建具有多个值的字段

时间:2021-08-13 10:06:59

First of all thank you for stopping by and reading this problem. So here's my problem. I have a table in mysql named tbl_section where the core fields should be:

首先感谢您停下来阅读这个问题。所以这是我的问题。我在mysql中有一个名为tbl_section的表,其核心字段应为:

  • section_id
  • SECTION_ID
  • section_name
  • SECTION_NAME
  • adviser_id
  • adviser_id
  • student_id
  • 学生卡

So here's the deal is it possible for 1 section to have multiple student_id's if so how should i go about it? I've tried looking into datatype Enum to solve this dilemma but all i got is nothing.

所以这里的交易是1个部分可能有多个student_id,如果是这样我应该怎么做呢?我已经尝试过研究数据类型Enum来解决这个难题,但我所得到的只是一无所获。

Hope you guys have a solution for this. Thank you for reading! The one who will solve this, I will make a statue of him and put it on my front yard like a GOD!!

希望你们有一个解决方案。谢谢你的阅读!谁会解决这个问题,我会制作一个他的雕像并像上帝一样把它放在我的前院!

1 个解决方案

#1


3  

Yes, you need master-detail tables or 1 to N relationship tables i.e.

是的,您需要主 - 详细信息表或1到N个关系表,即

create table section (
  section_id int,
  section_name varchar(100),
  adviser_id -- don't know what this field mean
)
create table student (
  section_id int,
  student_id int,
  student_name varchar(200)
)

then you may do like this

那么你可能会这样做

insert into section (1, 'section1', 0)
insert into student (1,10,'John Gordon')
insert into student (1,11,'Shor Khan')

then you can get all students in section1

那么你可以在第一部分找到所有学生

select * from student where section_id = 1

#1


3  

Yes, you need master-detail tables or 1 to N relationship tables i.e.

是的,您需要主 - 详细信息表或1到N个关系表,即

create table section (
  section_id int,
  section_name varchar(100),
  adviser_id -- don't know what this field mean
)
create table student (
  section_id int,
  student_id int,
  student_name varchar(200)
)

then you may do like this

那么你可能会这样做

insert into section (1, 'section1', 0)
insert into student (1,10,'John Gordon')
insert into student (1,11,'Shor Khan')

then you can get all students in section1

那么你可以在第一部分找到所有学生

select * from student where section_id = 1