【发布时间】:2016-11-28 14:50:28
【问题描述】:
我有 2 个表,假设表“a”和“b”.. 两个表都有相同的列.. 可以说 transaction_id 和 phone_number
这是表“a”的内容
buy | 1000
redeem | 1000
buy | 2000
redeem | 2000
这是表“b”
buy | 1000
redeem | 1000
buy | 2000
当我尝试加入他们以查找相似记录时,使用
select tablea.transaction_id, tablea.phone_number
from tablea a
inner join tableb b
on tablea.transaction_id = tableb.transaction_id
and tablea.phone_number = tableb.phone_number
我只得到
buy | 1000
redeem | 1000
最后一个类似的记录,“buy | 2000”总是丢失..为什么会这样?
【问题讨论】:
-
什么交易ID?什么电话号码?
-
无法重现您的问题:sqlfiddle.com/#!9/0aa460/1。请提供实际数据并查询