[plug] mysql query questoin

Jon Miller jlmiller at mmtnetworks.com.au
Sun Jan 19 22:17:52 WST 2003


If all fields were the same name that probably would work or better
still if there were no fields at all.  But in my case I have fields and
they are labeled differently than that of the source..

jlm

On Sun, 2003-01-19 at 21:53, levsky at rave.iinet.net.au wrote:
> On Sun, Jan 19, 2003 at 09:46:04PM +0800, Jon Miller wrote:
> > I guess what I need to know is does MySQL know that the table I want the
> > info to go into is in another database, if not how do I tell MySQL this
> > information?  I can understand if the two (2) tables resides in the same
> > database, but they don't.
> > 
> > JLM
> > 
> > On Sun, 2003-01-19 at 21:33, Onno Benschop wrote:
> > > On Sun, 2003-01-19 at 21:09, Anne Busby wrote:
> > > > Try
> > > > 
> > > > INSERT INTO <table2> SELECT <fields> FROM <table>;
> > > 
> > > And if you don't have field names that don't match-up, then you need to
> > > make it so:
> > > 
> > > INSERT INTO table (field1, field2, field3) SELECT peter AS field1, paul
> > > AS field2, mary AS field3 FROM table2 WHERE something='fred'
> > 
> I'd personally do that as. 
> 
> use db2;
> INSERT INTO table2 SELECT fields FROM db1.table1
> 
> It's worked for me before - in fact, I did it last week with about 78000
> rows..
-- 
Jon Miller <jlmiller at mmtnetworks.com.au>
MMT Networks Pty Ltd




More information about the plug mailing list