Using two databases in a query?

2003-03-20 Thread dreq jkj
Is it possible to use multiple databases in a query? (Privided that the user 
has correct permissions, that is)

I have tried to use mysql as root and make a such query, and got a result. 
The result, however, did look very strange.

database ccs_db.ccs_admin:
userID int unsigned
username...
database jobbguiden.jobbguiden_admin_user:
id int
username varchar(...)
Using select:
select
 jobbguiden.jobbguiden_admin_user.username,
 ccs_db.ccs_admin.username,
 ccs_db.ccs_admin.adminID
from
 ccs_db.ccs_admin left join
 jobbguiden.jobbguiden_admin_user 
on(ccs_db.ccs_admin.adminID=jobbguiden.jobbguiden_admin_user.id);

Result:
+--+--+-+
| username | username | adminID |
+--+--+-+
| mall | autorun  |   1 |
| stefan   | dbtransfer   |   2 |
| NULL | staffan grön |   3 |
   |   4 |tarina
|   5 |ffan
   |   6 |
   |   7 |
   |   8 |
  |   9 |
 |  10 |ha
 |  11 |an
 |  12 |el
 |  13 |an
 |  14 |el
 |  15 |ik
 |  16 |le
 |  17 |na
 |  18 |ny
   |  19 |
   |  20 |signer
+--+--+-+
All usernames from ccs_db has been trunkated in a strange manner...
Is this action completly un-supported, but semi-working...?
Btw; I'm running mysql 4.0.1-alpha...

//drew

_
Hitta rätt på nätet med MSN Sök http://search.msn.se/
-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)
To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


Indices in querys using OR...

2003-03-17 Thread dreq jkj
I have trouble figuring out how the indices are used when making a query 
that uses OR-operator.

If I have the following table:

create table testing(
id int unsigned not null primary key auto_increment,
idx1 int unsigned not null,
idx2 int unsigned not null,
index(idx1),
index(idx2));
In this query i expect mySQL to use one of the two indices to speed up the 
query, but It doesn't.. :(
select * from testing where idx1=0 or idx2=1;

The thing I'm thinking about instead is the following query:
select * from testing where idx1=0
UNION
select * from testing where idx2=1;
It looks like this does speed up the query, but is this the way to go???
Is this a weaknes in mySQL or have I forgotten something?
_
Hitta rätt på nätet med MSN Sök http://search.msn.se/
-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)
To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php