我試圖將表中的每個答案與其問題的標題連接起來。我知道嵌套查詢是一個壞主意。有沒有另一種方法來做到這一點?在同一個mysql表上結合了多個查詢
postid | type | parent_postid | title | content
----------------------------------------------------
1 | question | NULL | car wheels | how many
2 | answer | 1 | NUll | 4 wheels
SELECT * FROM table WHERE type = 'answer'
while($row = mysql_fetch_array($result)) {
$parent_postid = row['parent_postid'];
SELECT title FROM table WHERE postid = '$parent_postid'
}