NEW #1
Avatar
Zero2Cool Elite Member
Joined: Oct 14, 2006
Posts: 44,952
Avatar
Zero2Cool
Elite Member
Joined:Oct 14, 2006
Posts:44,952
I'm trying to clean up the database.

My goal is to remove the posts from members that have been deleted.

I want a select statement that shows me how many of them there are before deleting.


I think I'll be using three tables with this.

table (field)
    users
    (user_id)
    posts (poster_id)
    posts_text (post_id)


Every post is given and id number. Then that id number is assigned to the post text.

The relationship between users and posts is the user_id and poster_id.
The relationship between posts and posts_text is the post_id.

I tried this, but it didn't work so well.

[php]SELECT *
FROM posts LEFT JOIN users
ON posts.poster_id != users.user_id[/php]


I think I caused some site load errors with this query too, lol.
0
SlickVision, Methodikal, Kevin and 5 others
NEW #2
Avatar
dhpackr Registered
Joined: Dec 12, 2007
Posts: 963
Avatar
dhpackr
Registered
Joined:Dec 12, 2007
Posts:963
bummer you can't delete posts
0
SlickVision, Methodikal, Kevin and 5 others
NEW #3
Avatar
dhpackr Registered
Joined: Dec 12, 2007
Posts: 963
Avatar
dhpackr
Registered
Joined:Dec 12, 2007
Posts:963
don't you want to use count

SELECT posts, COUNT(*) FROM posts WHERE Posterid=poster_id GROUP BY poster_id;

you have to play around with the table names, and you add quite a bit to a query with 'where' & 'group by' as well as 'orderby'

just running a select or count query should not break the site
0
SlickVision, Methodikal, Kevin and 5 others
NEW #4
Avatar
Zero2Cool Elite Member
Joined: Oct 14, 2006
Posts: 44,952
Avatar
Zero2Cool
Elite Member
Joined:Oct 14, 2006
Posts:44,952
I dunno, do I?
0
SlickVision, Methodikal, Kevin and 5 others
NEW #5
Avatar
dhpackr Registered
Joined: Dec 12, 2007
Posts: 963
Avatar
dhpackr
Registered
Joined:Dec 12, 2007
Posts:963
you know the answer, just play around till you get the query.

wanna let me in?

i'll try
otherwise
this will help
0
SlickVision, Methodikal, Kevin and 5 others
NEW #6
Avatar
Nonstopdrivel Preferred Member
Joined: Sep 14, 2008
Posts: 18,544
Avatar
Nonstopdrivel
Preferred Member
Joined:Sep 14, 2008
Posts:18,544
I'm confused.
Are you wanting to clean up deleted posts or posts by deleted members?
The owner of the other board I used to administrate did the latter
routinely; unfortunately, some of the most prolific members (e.g., instructors) were getting deleted.
This resulted in some of our best threads being rendered nearly indecipherable, with members responding to phantom statements and questions.
Threads came to resemble Swiss cheese, with much of the best content missing, rendering them all but useless. If this is what you want to do, I'd urge caution in implementing it.
0
SlickVision, Methodikal, Kevin and 5 others
NEW #7
Avatar
Zero2Cool Elite Member
Joined: Oct 14, 2006
Posts: 44,952
Avatar
Zero2Cool
Elite Member
Joined:Oct 14, 2006
Posts:44,952
627 posts returned.


Every post should have a valid relationship to a member.
Every topic should have a valid relationship to a post.
Every post should have a valid relationship to a topic.

I don't want rogue data out there.
0
SlickVision, Methodikal, Kevin and 5 others
NEW #8
Avatar
Pack93z Select Member
Joined: Mar 17, 2007
Posts: 13,278
Avatar
Pack93z
Select Member
Joined:Mar 17, 2007
Posts:13,278
Yes use the count, cleaner approach for your request in the first post.. as a review.
0
SlickVision, Methodikal, Kevin and 5 others
NEW #9
Avatar
Pack93z Select Member
Joined: Mar 17, 2007
Posts: 13,278
Avatar
Pack93z
Select Member
Joined:Mar 17, 2007
Posts:13,278
Okay.. with the timeout error, more than likely due to query gen, my comment now seems out of place. lol.
0
SlickVision, Methodikal, Kevin and 5 others
NEW #10
Avatar
Zero2Cool Elite Member
Joined: Oct 14, 2006
Posts: 44,952
Avatar
Zero2Cool
Elite Member
Joined:Oct 14, 2006
Posts:44,952
627 is what I got back, which is just a list of members who have 1 or more posts.

The member list shows 618 with a post.

That to me means we have posts for 9 members that have been deleted.
0
SlickVision, Methodikal, Kevin and 5 others