开发者

MySQL Left join - odd problem

开发者 https://www.devze.com 2023-03-15 03:01 出处:网络
Running mySQL Community Server 5.5.13 Using the following query: select t1.f1, t2.f1, t2.f2 from t1 left join t2 on (t1.f3 = t2.f3)

Running mySQL Community Server 5.5.13

Using the following query:

select t1.f1, t2.f1, t2.f2
from t1 left join t2 on (t1.f3 = t2.f3)

If the left join finds no matches in table t2, rather than putting nulls in the values for t2.f1, t2.f2, it is actually putting the column names there.

Any suggestions why this migh开发者_如何学编程t be happening?


Try this:

SELECT `t1`.`f1`, `t2`.`f1`, `t2`.`f2`
FROM `t1`
LEFT JOIN `t2` ON `t1`.`f3` = `t2`.`f3`;
0

精彩评论

暂无评论...
验证码 换一张
取 消