mysql left join as_MySQL 一个left join 查询疑问

c_mart_order_info 表执行

mysql> SELECT order_id,order_sn FROM `c_mart_order_info` WHERE `order_sn` = '16030515100000196809';

+----------+----------------------+

| order_id | order_sn |

+----------+----------------------+

| 27 | 16030515100000196809 |

+----------+----------------------+

1 row in set (0.00 sec)

c_order_pay 执行

mysql> select order_sn from c_order_pay where order_sn=16030515100000196809;

+----------------------+

| order_sn |

+----------------------+

| 16030515100000196809 |

+----------------------+

1 row in set (0.00 sec)

两个表 left join 后

mysql> select a.order_sn as a_sn,c.order_sn as c_sn from c_mart_order_info as a left join c_order_pay as c on a.order_sn=c.order_sn where a.order_id=27;

+----------------------+------+

| a_sn | c_sn |

+----------------------+------+

| 16030515100000196809 | NULL |

+----------------------+------+

1 row in set (0.00 sec)

两个表都有相同的 order_sn 用left join 查询,为什么只得到一个表的信息,哪里出错了?

------更---------

感谢 woderwang 提醒,我的mysql 版本是5.1,col类型不一样造成,但是某些更新版本的mysql,却没有这个问题,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值