Relationship between post and post reply: mysqltwo tables, one table records the post, which is the parent table, one table records the reply of all posts, and the sub-table shows the Post ID with the parent table in the subtable, then, what statement should I use to query the reply content of each post and display it in each post. I asked this question again because I still don't know it. $ Str & quot; relationship between selectpinglun. mingzi, pinglun. neirongfrompi post and Post Reply
Mysql has two tables. one table records the post, which is the parent table, and the other table records the reply of all posts, which is the sub table.
The sub-table now has the post ID of the parent table,
Then, what statement should I use to query the reply content of each post and display it in each post.
I asked this question again because I still don't know it.
$ Str = "select pinglun. mingzi, pinglun. neirong from pinglun, tiezi where pinglun. id = tiezi. id ";
Are you sure you want to use the preceding two-table query statements?
------ Solution --------------------
Two table structures are given.
------ Solution --------------------
Parent post id = 1 table: table1
Sub-post pid = 1 table: table2
SELECT table2. *, t1.id FROM table2 AS t2, table1 AS t1 WHERE t2.pid = t1.id;
Well, it looks like this.
Is your comment id saved as a parent id? Can I use auto-incrementing... this must be saved to be associated with the parent id.