April 23rd, 2013, 03:13 PM
Insert data to joining table SQL
Hi, I'm confusing about the way to insert data to SQL. I have two tables like this:
and I join two tables to be
ID Reply Message
1 i A
2 ii A
3 iii A
4 iv B
For one message could have multiple replies. Now I have a data like this:
Message = [A,B]
Reply = [i,ii,iii,iv] *This is the just automatic order in the list but the actual data I need should be reply[i,ii,ii] for message A, reply[iv] for message B.
How can I insert these data properly in the join table? For example like:
con.execute("INSERT INTO Table1(Message) VALUES(%s),Message[i]")
<<< This should be Reply[i,ii,iii]
con.execute("INSERT INTO Table2(Reply) VALUES(%s),Reply[i]")
#Insert Message A first, and insert all replies in A. Then insert the message B and all replies for B.
Last edited by MynE; April 23rd, 2013 at 03:15 PM.