473,661 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create table from two another tables

2 New Member
Hi,
I have some problem...

I have two tables phpbb_posts and phpbb_posts_new with same fields and structure:

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `phpbb_posts` (
  2.   `post_id` mediumint(8) unsigned NOT NULL auto_increment,
  3.   `topic_id` mediumint(8) unsigned NOT NULL default '0',
  4.   `forum_id` smallint(5) unsigned NOT NULL default '0',
  5.   `poster_id` mediumint(8) NOT NULL default '0',
  6.   `post_time` int(11) NOT NULL default '0',
  7.   `post_created` int(11) NOT NULL default '0',
  8.   `poster_ip` varchar(8) NOT NULL default '',
  9.   `post_username` varchar(25) default NULL,
  10.   `enable_bbcode` tinyint(1) NOT NULL default '1',
  11.   `enable_html` tinyint(1) NOT NULL default '0',
  12.   `enable_smilies` tinyint(1) NOT NULL default '1',
  13.   `enable_sig` tinyint(1) NOT NULL default '1',
  14.   `post_edit_time` int(11) default NULL,
  15.   `post_edit_count` smallint(5) unsigned NOT NULL default '0',
  16.   PRIMARY KEY  (`post_id`),
  17.   KEY `forum_id` (`forum_id`),
  18.   KEY `topic_id` (`topic_id`),
  19.   KEY `poster_id` (`poster_id`),
  20.   KEY `post_time` (`post_time`)
  21. ) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=46104 ;
At phpbb_posts I have 58312 records.
At phpbb_posts_new I have 43470 records.

The phpbb_posts_new table is part of backup of phpbb_posts making at November 2006.
Why only part instead of full backup? Because archieve was broken :(

Two days ago by accident I delete more then 35000 records from my forum.
Currently I try repair part of them from backup.

Ok.
We have two tables.
At phpbb_posts I have 58312 records after accident.
And phpbb_posts_new has 43470 records.

What I need now...
I need create third table for example phpbb_posts_rep aired where place records from phpbb_posts_new which not exist in phpbb_posts.

Each record has unique `post_id`.

I am not MySQL guru.
I realy need help.

Thanx for all who will try help me.
Aug 8 '07 #1
3 2101
pbmods
5,821 Recognized Expert Expert
Heya, ScorpAL. Welcome to TSDN!

Try using a MySQL NOT EXISTS subquery:
Expand|Select|Wrap|Line Numbers
  1. INSERT
  2.     INTO
  3.         `phpbb_posts_repaired`
  4.     SELECT
  5.             *
  6.         FROM
  7.             `phpbb_posts_new`
  8.         WHERE
  9.             NOT EXISTS
  10.             (
  11.                 SELECT
  12.                         *
  13.                     FROM
  14.                         `phpbb_posts`
  15.                     WHERE
  16.                         `phpbb_posts`.`post_id` = `phpbb_posts_new`.`post_id`
  17.             )
  18.  
Aug 8 '07 #2
ScorpAL
2 New Member
WOW!
pbmods, you help me recover 13,801 posts!
Thanx a lot!

Later I will try recover phpbb_posts_tex t table.
And then generate phpbb_topics table.

Thanx again.
Aug 8 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, ScorpAL.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Aug 9 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
4051
by: Phil Powell | last post by:
create table if not exists nnet_produkt_varegruppe ( nnet_produkt_varegruppe_id int not null auto_increment, primary key(nnet_produkt_varegruppe_id), nnet_produkt_varegruppe_navn varchar(255) not null ); create table if not exists nnet_produkt_farge ( nnet_produkt_farge_id int not null auto_increment, primary key(nnet_produkt_farge_id),
5
3042
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I write some PHP code which should, I think, be able to to auto create the tables. The SQL looks like this:
3
752
by: Ben | last post by:
Hi everyone, Now I am using Visual Basic.net to write a program but having some headaches. The situation is as follows: I am using ODBC connection to connect one database( non-SQL server) , which has over 20 tables and each table has lot of fields. My aim is to setup a button, everytime when the button is clicked, the selected tables through the ODBC connection will be copied to a SQL server 2000 ( Both the data and table...
1
3349
by: poohnie08 | last post by:
i have a excel spreadsheet showing staff name, date,work hour, ot hour, slot1, slot2, slot3, slot4 and others). The "()" will keep repeating from day 1 until end of month. eg in excel spreadsheet, ============================================================================== A1 |A2 A3 A4 A5 A6 A7 A8 |A9 A10 A11 | 01/02/04 |02/02/04 StaffName |Work Hr OT Hr Slot1...
24
3099
by: flkeyman | last post by:
Work in legal office. Trying to create solid designed database structure. This is list of tables w/fields and primary keys. Any comments/advice greatly appreciated. tbl-Defendants CaseNumber (primary key) FirstName MiddleName LastName
2
3059
by: Mindy | last post by:
Hey, I want to create links between my two tables. The primary keys of these two tables are character variables, with length =11. I followed exactly the instruction of Dummuy Book for ACCESS 2003. I click the primary key of table A , and hold and move the mouse to table B. But nothing happened. No line, no error reminders. Does anyone know what's happened? Thanks. Mindy
3
10675
by: teedilo | last post by:
Our MS SQL (SQL Server 2000) DBA has database privileges locked down pretty tightly. We end users/developers do not have administrator privileges for most databases. That arrangement has worked out OK for the most part. However, it's a bit aggravating that we can't even create our own database diagrams. When we attempt to do so (in Enterprise Manager), we get a dialog that says "You do not have sufficient privilege to create a new...
27
3774
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB updates the same data in all other four tables in the right places. I know it would be possible by using the ForeignKeyConstraint object. I have created the tables using the DataSet Visual Tool and I know it doesn't create any ForeignKeyConstraint obj....
15
5263
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to show - text boxes, input boxes, buttons, hyperlinks ie the usual. The data is not obtained directly from a database.
3
7186
by: DeanL | last post by:
Hi guys, Does anyone know of a way to create multiple tables using information stored in one table? I have a table with 4 columns (TableName, ColumnName, DataType, DataSize) and wanted to know if there is a way to use the information in this table to create the many tables that are listed in the source table instead of creating each table individually? Many thanks for any help you can offer.
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.