今天查数据库遇到个怪现象,简单描述下
table1 表有一条记录
select * from table1 where id=1
可以查到这条记录,
关联table2表查询,
select a. from table1 left join table2 on a.id=b.aid where a.id=1
查询结果为null,table2中没有相关数据,但我只取table1数据,为什么也取不到
,也不是所有都取不到,a.id=2时就可以查到,
后来我换成
select a. from table1 left join table2 on a.id=b.aid where a.id like '1'
也能查出来,a.id和b.aid都是int型,aid设置为索引,有没有知道情况的