【发布时间】:2015-11-29 20:51:20
【问题描述】:
我有两张桌子。
表 A:
root_id, root_text
表 B:
word_id , word_text,root_text
现在Table B 的一些记录有可能在Table A 中不存在的root_texts。
因此,我正在尝试使用左连接。
select *
from A a , B b
where a.root_text=+b.root_text
我只得到匹配root_text的记录。
如果我使用新方法
Select
*
from
A left join B on a.root_text= b.root_text
我得到了很多额外的记录。我正在使用 MySQL 5.6.1.7
更新:
http://sqlfiddle.com/#!9/7b32a/2
查询我正在运行
select * from word_detail w left join roots r
on r.root_text =w.root
and w.surah_no=1
and w.verse_no=1
and w.word_no=1
我做错了什么?
作为结果,您会看到很多不需要的记录。过滤器 verse_no , word_no 不起作用。
更新
问题是在左连接之后我们必须使用 where
select * from word_detail w left join roots r
on r.root_text =w.root
where w.surah_no=1
and w.verse_no=1
and w.word_no=1
【问题讨论】:
标签: mysql sql select left-join