Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select & Insert across multiple databases with MySQL

I have 2 identical tables in 2 different databases that reside on the same server. What would be the best way to copy data from table to another?

like image 631
GSto Avatar asked Aug 03 '10 18:08

GSto


People also ask

What is select option?

Definition and Usage. The <select> element is used to create a drop-down list. The <select> element is most often used in a form, to collect user input. The name attribute is needed to reference the form data after the form is submitted (if you omit the name attribute, no data from the drop-down list will be submitted) ...

How does select membership work?

SELECT is an experiential, membership only rewards platform that transforms any credit or debit card into a black card. For an annual fee of $300, SELECT offers exclusive pricing and VIP treatment at hotels, restaurants, retailers, entertainment venues and more.

What is a select element?

The select element represents a control for selecting amongst a set of options. The multiple attribute is a boolean attribute. If the attribute is present, then the select element represents a control for selecting zero or more options from the list of options.

What is JavaScript select?

JavaScript provides six methods to select an element from the document. getElementById – search element by element_id. getElementsByTagName – search element by tag name (e.g., span, div) getElementsByClassName – search element by class name. getElementsByName – search element by name attribute.


1 Answers

Use:

INSERT INTO db1.table1
SELECT *
  FROM db2.table2 t2
 WHERE NOT EXISTS(SELECT NULL
                    FROM db1.table1 t1
                   WHERE t1.col = t2.col)

The exists is simplified, but you left out if there's a primary key/auto_increment to worry about/etc.

like image 119
OMG Ponies Avatar answered Sep 30 '22 02:09

OMG Ponies