Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 intertwining tables for mysql

Author  Topic 

userprofile
Starting Member

1 Post

Posted - 2009-10-11 : 02:23:06
I am a beginner in mysql. I know the basics of selecting and inserting values.

I am not too sure what my problem is called. I hope someone can help me.

In my database I have 2 tables for a forum,

Table 1: threads
which contains rows threadid(int) with auto increment and postid (int) and other threads related data

Table 2: posts
which contains rows threadid (int) and postid (int) with auto increment and other posts related data.

I want to insert a value into the tables threads and posts. I am trying to intertwine the two tables.

ie: Table 1 has threadid = 5. When I do an insert, it will turn to 6.

Table 2 has postid = 50. When I do an insert, postid will go to 51.

I want to write sql code that will insert a new value that will be written to both tables. ie, when I insert into, the value will be threadid 6 and postid 51 for both tables. And not like two separate "insert into" code that will give me table 1 threadid = 6 postid = 0 and table 2 threadid = 0 and postid = 51.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-11 : 14:26:37
i'm not sure why you've included both ids in both master tables. i would have included only either of them in master(threadid in thread and postid in posts) and represented their relation by another table
Go to Top of Page
   

- Advertisement -