PDA

View Full Version : Help with a query...


vbplusme
01-12-2009, 06:34 AM
Hello and Happy New Year to All!

I have this query to find the latest post and it works great.

$sql = " SELECT `pagetext`, `postid` FROM `post` WHERE `pagetext` LIKE '%content%'ORDER BY `postid` DESC LIMIT 1 ";

$result=mysql_query($sql) or die(mysql_error());

Now, I need to find the latest post that is made in a particular forum. When I started checking into what the query needed to be, I discovered that the `post` table has no direct reference to the forum that contains the post but indirectly uses the `threadid` and the `thread` table has the forumID reference. So the question is, how do I modify the above to SELECT the latest post from a specific Forum?

Any help greatly appreciated

TIA

Dismounted
01-12-2009, 07:16 AM
You need to use MySQL joins. Google has plenty of tutorials, but I will point you to one: http://www.tizag.com/mysqlTutorial/mysqlleftjoin.php.