SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
-
Oct 14, 2009, 09:51 #1
- Join Date
- Oct 2007
- Posts
- 14
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
SQL Moving Data Between Many Tables
Hi,
On moving data between tables:
This is a problem I have where I want to move a record from an 'enquirer' table into a 'student' table, and then add their course interests from the old 'enquirer interests table' into the new 'student interests' table.
In other words, I want to take a record from the enquirer table and pass this into the student table, whereby the enquirer becomes a student, and a new id for this student will be an auto incremented number. After this, I want to take the enquirer's (who has become a student) interests from the 'enquirer interests' table and place these interests into the 'student interest's' table, and the interests will be linked to the new id which was generated when the enquirer became a student.
So far, I can pass the enquirers details into the student table, no problem. But how do i pass the interests from the enquirer interests table into the students interests table using the new incremented id that uniquely identified the student?
I know sometimes people just select last id in the student table, but this is not recommended. Is there another way to link the students interests to the new student id?
Thanks in advance,
J
-
Oct 14, 2009, 10:17 #2
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
have you thought about using just one table with a special column to distinguish enquirers from students? you wouldn't have to move anything then
-
Oct 15, 2009, 05:41 #3
- Join Date
- Oct 2007
- Posts
- 14
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Is it good practise to use a column with values either 1 for student, and 0 for enquirer?
-
Oct 15, 2009, 05:45 #4
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
yes, that works nicely
Bookmarks