Re: Importing table contents

2010-01-02 Thread Gary Smith

Patrice Olivier-Wilson wrote:
I have 2 databases, different domains. Both have a table named 
'tips'... both have different contents in the table.

Using phpMyAdmin for GUI.

I want to export databaseA tips as sql (done) then import content into 
databaseB tips. But when I run that operation, the databaseB says that 
there is already a table named tips in databaseB.


Yep, know that... I want to bring in the contents...not make a new table.

Any help, most appreciated
When you export, PHPMyAdmin has the option to add drop table. This will 
drop the existing table structure and create a new one as it was when it 
was exported. Is this what you're after?


Gary

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: Importing table contents

2010-01-02 Thread Patrice Olivier-Wilson

Gary Smith wrote:

Patrice Olivier-Wilson wrote:
I have 2 databases, different domains. Both have a table named 
'tips'... both have different contents in the table.

Using phpMyAdmin for GUI.

I want to export databaseA tips as sql (done) then import content 
into databaseB tips. But when I run that operation, the databaseB 
says that there is already a table named tips in databaseB.


Yep, know that... I want to bring in the contents...not make a new 
table.


Any help, most appreciated
When you export, PHPMyAdmin has the option to add drop table. This 
will drop the existing table structure and create a new one as it was 
when it was exported. Is this what you're after?


Gary


I have data I need to keep in both db just trying to merge.



--
Patrice Olivier-Wilson
888-385-7217
http://biz-comm.com


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: Importing table contents

2010-01-02 Thread Gary Smith

Patrice Olivier-Wilson wrote:

I have data I need to keep in both db just trying to merge.

There's two ways around this:

First is to not export the structure (uncheck structure). The second is 
to export with if not exists. This should (IIRC) do a create table if 
not exists, so it'll do what you're wanting to do.


Do you have any primary keys/auto increment columns that are going to 
overlap or anything like that?


Cheers,

Gary

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: Importing table contents

2010-01-02 Thread Patrice Olivier-Wilson

Gary Smith wrote:

Patrice Olivier-Wilson wrote:

I have data I need to keep in both db just trying to merge.

There's two ways around this:

First is to not export the structure (uncheck structure). The second 
is to export with if not exists. This should (IIRC) do a create 
table if not exists, so it'll do what you're wanting to do.


Do you have any primary keys/auto increment columns that are going to 
overlap or anything like that?


Cheers,

Gary


Gave it a try got this:
MySQL said:

#1062 - Duplicate entry '1' for key 1

--
Patrice Olivier-Wilson
888-385-7217
http://biz-comm.com


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: Importing table contents

2010-01-02 Thread Gary Smith

Patrice Olivier-Wilson wrote:

Gave it a try got this:
MySQL said:

#1062 - Duplicate entry '1' for key 1
Yeah, that's what I was saying about in my previous mail. It looks like 
you've got a primary key on one of your columns, and you're attempting 
to insert data into it with a duplicate primary key (ie what the error 
message says). The easiest way to get around this one would be to write 
a query that pulls all of the columns apart from the primary key, and 
then replace that field with '' or somesuch.


For instance, let's say you've got a schema of the following:

table1(primarykey,column2,column3,column4,column5)

primarykey is obviously a primary key. You'd do something along the 
lines of select '',column2,column3,column4,column5 from table1;


Then export that resultset to an SQL file.

Anyone else aware of an easier way to do this? I've got into some bad 
habits over the years, but I'm not aware of another way to do what 
Patrice is trying to do.


Cheers,

Gary

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: Importing table contents

2010-01-02 Thread Patrice Olivier-Wilson

Gary Smith wrote:

Patrice Olivier-Wilson wrote:

Gave it a try got this:
MySQL said:

#1062 - Duplicate entry '1' for key 1
Yeah, that's what I was saying about in my previous mail. It looks 
like you've got a primary key on one of your columns, and you're 
attempting to insert data into it with a duplicate primary key (ie 
what the error message says). The easiest way to get around this one 
would be to write a query that pulls all of the columns apart from the 
primary key, and then replace that field with '' or somesuch.


For instance, let's say you've got a schema of the following:

table1(primarykey,column2,column3,column4,column5)

primarykey is obviously a primary key. You'd do something along the 
lines of select '',column2,column3,column4,column5 from table1;


Then export that resultset to an SQL file.

Anyone else aware of an easier way to do this? I've got into some bad 
habits over the years, but I'm not aware of another way to do what 
Patrice is trying to do.


Cheers,

Gary

If I export both db tables into csv, combine and then import back, that 
should do it, methinks...


just create a new table called tips2, merge the 2 into one...

--
Patrice Olivier-Wilson
888-385-7217
http://biz-comm.com


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org