Jump to content

php inner join


chriscloyd

Recommended Posts

I have two results could 

$result = mysql_query("select CommentID, CommentName, CommentLikes, CommentAuthor, CommentDate from Comments where BlogID = '{$blogID}' and SubComment = '0' and Access >= '{$User->info['Access']}' order by {$sort} limit {$limit}");
		

$result2 = mysql_query("select CommentID, CommentName, CommentLikes, CommentAuthor, CommentDate from Comments where SubComment = '{$cline['CommentID']}' and Access >= '{$User->info['Access']}'");
			

can i inner join to get the sub comments right after the main comments, even though they are in the same table?

 

Link to comment
https://forums.phpfreaks.com/topic/277913-php-inner-join/
Share on other sites

Try,

$sql = "select CommentID, CommentName, CommentLikes, CommentAuthor, CommentDate from Comments where 
BlogID = '{$blogID}' AND CommentID IN (
select CommentID from Comments where 
SubComment = '{$cline['CommentID']}' and Access >= '{$User->info['Access']}')";
Link to comment
https://forums.phpfreaks.com/topic/277913-php-inner-join/#findComment-1429650
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.