I want to create a table with two columns - name and courses. So, let's say for the first row, I want to insert John into the name column, and insert maths, English, chemistry into the courses column(the same row as name-John). Is this possible with php/mysql.
You can save 3 rows with name set to John for each of Maths, Chemistry and English.
Just add another column asy ' name_id
' which is same for the three rows.
That way, if you want to see this particular John's subjects, you can fetch his subjects SELECT courses FROM student_db WHERE name_id="xx"
That would be a easier way.
If you want a single row for John then
INSERT INTO student_db (name,courses) VALUES ('John','Maths,Chemistry,English')
should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.