小编Ins*_*DHD的帖子

简单的MySQL加入varchar(100)字段不起作用

所以,我正在加入mysql以过滤掉一些不良数据,我遇到了这个奇怪的问题.

  • 两个表都连接在一起payment_transaction_id.
  • 他们都有价值3463.
  • 联接结果不返回任何行.
  • 两个表都有此值.

证明记录在card_transaction_log中:

select count(*)
from card_transaction_log 
where payment_transaction_id = 3463;
>> 1
Run Code Online (Sandbox Code Playgroud)

证明记录在交易中:

select count(*)
from transaction 
where payment_transaction_id = 3463;
>> 1
Run Code Online (Sandbox Code Playgroud)

但是加入不起作用.

select count(*)
from card_transaction_log a, transaction b
where a.payment_transaction_id = b.payment_transaction_id
and a.payment_transaction_id = 3463;
>> 0
Run Code Online (Sandbox Code Playgroud)

老实说,我以前从未在mysql中见过这样的东西.我甚至和我的同事核实过,以确保我不会疯狂和/或愚蠢.

更新:

虽然这与上面相同,但此查询也不起作用:

select count(*)
from card_transaction_log a
join transaction b
on a.payment_transaction_id = b.payment_transaction_id
where a.payment_transaction_id = 3463;
>> 0
Run Code Online (Sandbox Code Playgroud)

mysql

4
推荐指数
1
解决办法
1897
查看次数

标签 统计

mysql ×1