-1

I have a table "names" which looks like |name | |-----| |name1| |name2| |name3| |.....| From this table, I want to use the names as column names for another table "form" |id|name1|name2|name3|...

The items under "names" are not fixed. I don't know exactly how many items are there. How do I create this table "form" like this by using php and SQL?

Dharman
  • 30,962
  • 25
  • 85
  • 135

1 Answers1

0

if I understand the question what you need is to have a reference of a table in another one. You can achieve this using foreign keys. They allow you to reference entries of table in another. For example if I have a table "students" and another one "parents" and I want to know who are the parents of one student I can have in my table "students" a field "ID" that will identify my students uniquely (primary key) and then I will use this identifier in my table "parents" (as a foreign key). Hence, I will not be able to add a parent with and invalid student ID (that will mean, the unknown student has 'parent_name' as parent which would make no sense).

Primary, and Foreign are SQL topics

MarK
  • 41
  • 5