Click to See Complete Forum and Search --> : [RESOLVED] Joins explained for the really dumb


1andyw
02-11-2007, 09:38 AM
I am trying to deal with a backup of a phpbb forum RDB that consists of 27 tables; and is very well designed.

I am having trouble writing queries and understanding joins.

Will someone direct me to a tutorial on joins at the most basic level.

Thanks,

Andy

NightShift58
02-11-2007, 06:46 PM
What do you mean by "trying to deal with a backup of phpBB"?

Are you trying to make a backup of the database?

1andyw
02-11-2007, 08:40 PM
I am using the 'backup database' function from the phpbb admin panel and saving it to my hard drive.

The phpbb will be used for posts for a ten week stretch, then all the posts and registers will be deleted. Then the process goes on for a new ten week stretch.

My goal is to dump the info to file before I delete the entries.

I may get stuck in the position where I must leave the bb alone until Saturday morning and have it cleaned for a new cycle on Monday morning.

I'm trying to set up a few php files to report the saved posts from my backup file.

I need to list the text, subject, and author for each post, ordered by post_id where forum_name='$_POST[forum]' and cat_title='$_POST[category]'.

This $sql$sql="SELECT `phpbb_posts_text`.`post_subject` , `phpbb_posts_text`.`post_text` , `phpbb_users`.`username` , `phpbb_categories`.`cat_title` , `phpbb_forums`.`forum_name` FROM phpbb_posts_text, phpbb_users, phpbb_categories, phpbb_forums inner join phpbb_posts on `phpbb_posts`.`post_id`=`phpbb_posts_text`.`post_id` join phpbb_posts on `phpbb_users`.`user_id`=`phpbb_posts`.`poster_id` WHERE cat_title='$_POST[category]' and forum_name='$_POST[forum]'";

was working before I added the 'joins' but returned too many records. As it is now, it return 'supplied argument is not a valid MySQL result'. If I delete the joins, it works but returns all the posts.

The file dump is attached but it is large.

Thanks for the look, nightshift.

1andyw
02-12-2007, 02:32 PM
I have it figured out. I need to optimize the query, but that is another post.

Andy