在一个mysql5.0的服务器上建有两个库DA,DB DA中有表room,DB中有表user 两个表通过 room.userid=user.id关键。现在想查询 user.id=0001 and user.pwd=123 and room.userid=001的记录,如何实现。select * from da.room r, db.user u where r.userid = u.id and u.id = 001 and u.pwd = 123
报错, 找不到表 select rooms.name,rooms.userid from DA.rooms as rooms where rooms.userid=1001001 and DB.user.id=1001001 and DB.user.pwd='123'执行报错:Unknow table DB.user
select rooms.name,rooms.userid from DA.rooms as rooms -- from 中少了 DB。User where rooms.userid=1001001 and DB.user.id=1001001 and DB.user.pwd='123'
select r.name, r.userid from DA.rooms r, DB.user u where r.userid = u.id and u.id = 1001001 -- 如果 id 是字符类型的, 这里应该是 ='1001001' and u.pwd = '123'
两个表通过 room.userid=user.id关键。现在想查询
user.id=0001 and user.pwd=123 and room.userid=001的记录,如何实现。select *
from da.room r,
db.user u
where r.userid = u.id
and u.id = 001
and u.pwd = 123
select rooms.name,rooms.userid from DA.rooms as rooms where rooms.userid=1001001 and DB.user.id=1001001 and DB.user.pwd='123'执行报错:Unknow table DB.user
select rooms.name,rooms.userid
from DA.rooms as rooms -- from 中少了 DB。User
where rooms.userid=1001001
and DB.user.id=1001001
and DB.user.pwd='123'
from DA.rooms r,
DB.user u
where r.userid = u.id
and u.id = 1001001 -- 如果 id 是字符类型的, 这里应该是 ='1001001'
and u.pwd = '123'