vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   MySQL Issus: copy from tables (https://vborg.vbsupport.ru/showthread.php?t=176630)

FatalBreeze 04-19-2008 03:27 PM

MySQL Issus: copy from tables
 
Hello!
A moderator in my forum has deleted like 40,000 users from the DB.
Now i have a backup but in difference of times between the backup and the deletion, lot a new members registered.
I only want to copy the users from one old user table in the old DB to the new user table in the new DB, but if the userid already exists, dont copy the row and continue to the next row.

What is the SQL command for that?

Thanks in advance.

Marco van Herwaarden 04-19-2008 03:29 PM

You can not restore just 1 table, they are all linked together.

FatalBreeze 04-19-2008 07:48 PM

I'm not talking about restore, i'm talking about using a query, select the data from user1 and copy it to user2.

And if i can't do that, so what other solution do you offer?

Marco van Herwaarden 04-20-2008 08:02 AM

That would be a partial restore of a single table. This will not work.

My best suggestion is to simply restore the database and take the loss of new posts.
Alternative would be to restore to a temporary database, clean the temp. forum from all other users/posts/etc.. then use ImpEx to merge.

FatalBreeze 05-04-2008 07:53 AM

I dont need to use the impex.
I dont really care about those 40,000 users, only for their email address and the forum stats, not about their posts and etc.

I can use the query INSERT ... SELECT, but i don't know how to use the ON DUPLICATE KEY, i want it to do nothing if the key already exists.

Can you please add more light on this query?

Is it possible that the query should be:
Code:

INSERT IGNORE INTO `user` (userid, username, ...)
SELECT * FROM `user_backup`;


Eikinskjaldi 05-05-2008 12:59 AM

yes, though you would be better explicitly naming the backup fields

[sql]
INSERT IGNORE INTO `user` (userid, username, ...)
SELECT userid,username... FROM `user_backup`;
[/sql]

Marco van Herwaarden 05-05-2008 09:32 AM

You should not restore (data from) single tables, this will most likely break your board!!

Eikinskjaldi 05-06-2008 03:12 AM

Roman Law Marco. It's his to break :)

FatalBreeze 05-09-2008 07:01 AM

It didn't break my board, i backed up everything first, and it worked fine, Thanks Eikinskjaldi!


All times are GMT. The time now is 05:05 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05451 seconds
  • Memory Usage 1,722KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete