我有两个表我想在使用LEFT OUTER JOIN时添加一个条件
select tt.description,tt.visible,vct.currvalue
from tblemployee tt
left outer join viwcurrentemployee vct on vct.transitiontype = tt.cid
and vct.employee = 63
and tt.visible = 1
order by tt.cid
Run Code Online (Sandbox Code Playgroud)
我只想要那些有可见= 1的记录是真的但查询忽略条件和一件事我必须要使用左外连接因为我想要从左表记录甚至记录不存在于右表中如何检查条件我将只从左表中获得可见为1的那些记录
Mik*_*son 12
试试这个
select tt.description,
tt.visible,
vct.currvalue
from tblemployee tt
left outer join viwcurrentemployee vct
on vct.transitiontype = tt.cid and
vct.employee = 63
where tt.visible = 1
order by tt.cid
Run Code Online (Sandbox Code Playgroud)
我转而tt.visible = 1去了where子句.vct.employee = 63需要保持联接,否则你将没有外连接.
| 归档时间: |
|
| 查看次数: |
15291 次 |
| 最近记录: |