Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2006-11-24, 05:02 PM
Junior Member
 
Join Date: Nov 2006
Posts: 5
mikehammond is on a distinguished road
Default 1st post newbie SQL help

Hello all, I'm hoping you guys can help me out with MySql 4.1.19.

For my sins I'm an admin on a phpbb forum and in one section someone managed to delete all the topics & posts.

I have found the tables concerned in a backup database they are phpbb_topics, phpbb_posts and phpbb_posts_text.

The first two (phpbb_topic and phpbb_posts) are easy enough to sort using a field called forum_id which in this case has a value of 39 for all the posts I need to reinsert the data, but the third table (phpbb_posts_text) does not have the forum_id field in it.

phpbb_posts_texts does however share another field with the phpbb_posts table which is post_id (this is a unique reference for each post under a specific topic)

So how do I extract the phpbb_posts_texts data only related to the values in phpbb_posts table for the post_id values that also have forum_id of 39 ?

Many thanks I hope it makes sense ?


Mike

PS I use phpMyAdmin
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2006-11-25, 03:20 AM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

It makes sense.

Ok, the best thing to do is create a temporary database and put your backup in there.

Then delete all the records from post and topic that are not from the forum you need.

Then run a query to delete all the unrelated post_text from that table. It would look something like:

delete from phpbb_post_text where post_id not in (select post_id from phpbb_post);

Then, export the three remaining tables, import those into your live database, and you are set.
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #3 (permalink)  
Old 2006-11-25, 11:46 AM
Junior Member
 
Join Date: Nov 2006
Posts: 5
mikehammond is on a distinguished road
Default

Thanks for that I'll have a tinker and see if I can work it out from that.

Cheers

Mike
Reply With Quote
  #4 (permalink)  
Old 2006-11-25, 12:29 PM
Junior Member
 
Join Date: Nov 2006
Posts: 5
mikehammond is on a distinguished road
Default

OK cleared out all the stuff out of phpbb_topics and phpbb_posts that don't have a forum_id of 39, that's worked fine so stage one complete.

Then when I try to run the query on phpbb_posts_text I'm getting a syntax error. I'm close but no cigar, can you or anyone ?? see where I'm going wrong ??

DELETE FROM 'phpbb_posts_text' WHERE 'post_id' NOT LIKE (SELECT 'post_id' FROM 'phpbb_posts');

Thanks

Mike
Reply With Quote
  #5 (permalink)  
Old 2006-11-25, 02:58 PM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

Use NOT IN, not NOT LIKE
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #6 (permalink)  
Old 2006-11-25, 03:14 PM
Junior Member
 
Join Date: Nov 2006
Posts: 5
mikehammond is on a distinguished road
Default

Quote:
Originally Posted by Xnuiem View Post
Use NOT IN, not NOT LIKE
It didn't like that either ?
Reply With Quote
  #7 (permalink)  
Old 2006-11-25, 03:33 PM
Junior Member
 
Join Date: Nov 2006
Posts: 5
mikehammond is on a distinguished road
Default

Sorted, typo on my part

thanks for your help

Mike
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:25 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.