我有插入註釋數據和評論數據這樣的兩個MySQL表:PHP連接兩個MySQL表中的結果
評論:
|id|post_id|text|name|timestamp|approved|parent_id|type|ip|
評論:
在行動我|id|postID|comments_id|reviewfield1|reviewfield2|reviewfield3
爲每條評論插入一條評論。現在,我需要證明與評論name
/打印評論列表和text
+ reviewfield1
reviewfield2
reviewfield3
對於那些評論是approved
這樣每個評論:
commenter 1
text
reviewfield1
reviewfield2
reviewfield3
TRY:
"SELECT name,text,timestamp FROM " . COMMENTS . " LEFT JOIN " . REVIEWS . " WHERE " . COMMENTS . ".id = " . REVIEWS . ".comments_id AND
post_id = ? AND type = ? AND approved = 1 ", $id, $type"
但這不是工作我。如何使用PHP JOIN
方法生成這個?
你嘗試過什麼嗎? – Ahmad
你是一個聰明的人。你有這麼遠。繼續 – Drew
http://dev.mysql.com/doc/refman/5.6/en/join.html – Lynxi