请教:左连接的过滤条件为什么不执行?
这样一个sql语句:
select id,tableB.name,content from tableA
LEFT JOIN
tableB on tableB.id = tableA.id
and tableA.fieldB = 'B'
两个表tableA和tableB,A表显示人员id,而B表存人名,我想显示A表所有字段并把B表的人名显示.另外加一个过滤条件就是tableA.fieldB='B',但这个过滤条件不起作用,请教一下我写错了嘛?
多谢各位~~
问题点数:100、回复次数:6Top
1 楼libin_ftsafe(子陌红尘:TS for Banking Card)回复于 2006-03-08 16:30:18 得分 50
select id,tableB.name,content
from
tableA
LEFT JOIN
tableB
on
tableB.id = tableA.id
where
tableA.fieldB = 'B'
Top
2 楼lsqkeke(可可)回复于 2006-03-08 16:35:04 得分 30
select id,tableB.name,content
from
tableA a
LEFT JOIN
tableB b
on
a.id = b.id
where
a.fieldB = 'B'Top
3 楼moonshineidolon(神)回复于 2006-03-08 16:35:11 得分 0
语法没有错误Top
4 楼moonshineidolon(神)回复于 2006-03-08 16:36:28 得分 0
select id,tableB.name,content
from
tableA
inner JOIN
tableB
on
tableB.id = tableA.id
and
tableA.fieldB = 'B'
试试Top
5 楼gold_water(风雨无阻)回复于 2006-03-08 16:40:10 得分 20
select id,tableB.name,content
from
tableA a //问题应该是在这里
LEFT JOIN
tableB b //问题应该是在这里
on
a.id = b.id
where
a.fieldB = 'B'
Top
6 楼flame001(flame001)回复于 2006-03-08 17:01:42 得分 0
谢谢大家啊,问题解决,是and的问题应该改为where:)Top




