Sorry to bother you once more on this David, but I am having trouble
figuring out how to run a query on tables in two different databases.
I normally use
/usr/local/mysql/bin/mysql -h localhost -u username -ppassword -D
databaseName -N -e SELECT ...
as the initial string of the query. However, this only references one
database. How can I issue a query over two tables, one in each
database?
Thanks,
John
On Dec 11, 2005, at 7:02 PM, Logan, David (SST - Adelaide) wrote:
No problem, good to see a result.
Regards
David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia
+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax
-----Original Message-----
From: John Mistler [mailto:[EMAIL PROTECTED]
Sent: Monday, 12 December 2005 1:30 PM
To: Logan, David (SST - Adelaide)
Subject: Re: Import Table?
Aha, that's it! I didn't think about the fact that you can run queries
on tables in multiple databases in that manner.
The end result is exactly the same.
You made my day. Thanks!
-John
On Dec 11, 2005, at 6:35 PM, Logan, David (SST - Adelaide) wrote:
Hi John,
I would probably create a temporary database, use this, dump all the
tables into that and then use only the table that you want, followed
by
a drop database. It would be a bit difficult to strip out one table
AFAIK. I can't see anything in the mysql client options.
eg. mysql -u root -p <new databasename> <./.sql file
If you are embedding this into the app, is this perl or similar? You
can
either do a create tempdatabasename or use the test database that
seems
to be created by every mysql installation and just do a mysql -u root
-p
test <./.sql file
Your comparisons can refer to permanent.tablename and temp.tablename.
They will be logically and physically separate. eg. you can JOIN etc.
so
long as you have the permissions.
Sorry I can't be of more help.
Regards
David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia
+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax
-----Original Message-----
From: John Mistler [mailto:[EMAIL PROTECTED]
Sent: Monday, 12 December 2005 12:46 PM
To: Logan, David (SST - Adelaide)
Subject: Re: Import Table?
David,
I should probably just give the big picture of what I need to
accomplish. Here it is:
I am on Mac OS X.3.
The sql file was dumped from the same database at an earlier date
using
mysqldump.
The database has 6 tables in it, one of which is the table I want to
access -- 'theTable'.
The end goal is to load 'theTable' from the dumped sql file into a
temporary table on the server in order to do some comparisons between
'theTable' currently in the server and 'theTable' from the sql file.
I am embedding these mysql commands into my MAC OS X application's
code, so cutting and pasting data is not relevant to my situation.
Thanks for sticking with me on this!
-John
On Dec 11, 2005, at 5:57 PM, Logan, David (SST - Adelaide) wrote:
Hi John,
Personally, I'd just do a cut and paste job on the .sql file unless
it
is too unmanageable. Not knowing your platform, and being a unixy
type
person, I would use sed or grep to strip out the lines that I need
and
then plonk them straight into another file. I don't know how you
could
accomplish that on a Windows platform.
I hope I haven't misunderstood, is the .sql file come from another
MySQL
database or is this from a SQL server machine or similar? My
interpretation of a .sql file is something akin to that created by
mysqldump eg. a text file that has a number of SQL statements in it
allowing you to recreate the table by using this as input.
You can also use
Regards
David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia
+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax
-----Original Message-----
From: John Mistler [mailto:[EMAIL PROTECTED]
Sent: Monday, 12 December 2005 12:14 PM
To: mysql@lists.mysql.com; Logan, David (SST - Adelaide)
Subject: Re: Import Table?
Thanks for the response, David. How about if I want to import all
the
entries from one specific TABLE within that sql file into a table
with
identical columns on my MySQL server? Is there a way?
Thanks,
John
On Dec 11, 2005, at 5:29 PM, Logan, David (SST - Adelaide) wrote:
Hi John,
If it is a ".sql" file, with all appropriate SQL statements already
in
place then you only have to do the following
$ mysql -u xxxx -p databasename <.sql file
This will process all appropriate statements in the file.
Regards
David Logan
Database Administrator
HP Managed Services
148 Frome Street,
Adelaide 5000
Australia
+61 8 8408 4273 - Work
+61 417 268 665 - Mobile
+61 8 8408 4259 - Fax
-----Original Message-----
From: John Mistler [mailto:[EMAIL PROTECTED]
Sent: Monday, 12 December 2005 11:55 AM
To: mysql@lists.mysql.com
Subject: Import Table?
Is there a command that will load in all of the data from a table
within a database ".sql" file on disk? The only import option I am
seeing is "LOAD DATA INFILE" which requires a text file already
exported to disk. How about a way to load in the table data
directly
from the database file?
Thanks,
John
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]