你能在PHP / MySQL中的数据库表中的每一行中创建/插入表吗?

问题描述:

Is it possible? If yes, how?

I am using xampp for my database and I wanted to make a database with "students" table, only one column for the list of student IDs, and every student ID has another table inside. (I was considering making tables for every student ID so that it can be done directly but it seems that it PHP/MySQL does not allow integers as table name).

有可能吗? 如果是,怎么做? p>

我正在使用xampp作为我的数据库,我想用“学生”表创建一个数据库,只有一列用于学生ID列表,每个学生ID 里面有另一张桌子。 (我正在考虑为每个学生ID制作表格,以便可以直接完成,但似乎PHP / MySQL不允许整数作为表名。) p> div>

No, you cannot put tables inside a row in SQL. That's not compatible with the concept of a relational database. What you can do is provide a foreign key to another table where you can collect the data you need to link to your first table.

What you need is to have one table with all you want about the students, and add a field with their ID.

So, yo don't have to get the information from student #123 as

SELECT * FROM 123

but

SELECT * FROM students_table WHERE IdStudent = 123