James Black [EMAIL PROTECTED] wrote on 04/01/2005 04:11:49 PM:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Is it possible to have a stored procedure query another database?
I have two databases where the second (B) uses information from (A) to
make decisions.
It would be great if the stored procedure on database B could query A,
so that it can make decisions.
I am using mysql 5.0.3 if it matters.
Thanx.
- --
Love is mutual self-giving that ends in self-recovery. Fulton Sheen
James Black[EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCTbkVikQgpVn8xrARAk3tAJ9hgTrZZktxWhQc7JsH5jObS9NbcACfZBo0
NmYnKlIeJEzBiqUpaYsdTzg=
=eDx8
-END PGP SIGNATURE-
If you mean can you query another database on the same server, the
answer is YES. If you mean query another database on a different server,
I don't know for certain but I don't think so.
All you have to do to query a table in any database on your server is to
qualify the table's name with the name of the database it is in. For
instance, I can see a list of all of the user accounts of the server I am
logged into if I say
SELECT * from mysql.user;
and because I put the database's name in front of the table name, it
doesn't matter which database I run it from (which database I USE-ed
last). I don't expect that behavior to change just because a query is
inside a stored procedure.
Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine