【发布时间】:2016-06-30 02:12:04
【问题描述】:
select * from inventory.home_picture_types hpt
left join inventory.home_pictures hp on hp.home_picture_type_id = hpt.id
where hp.id IS NULL;
此查询适用于 vagrant/homestead,并返回 home_picture_types 的 home_picture 值为 NULL(正确,我只是想获取 home_picture_types)。
但是,当我在 CentOS Maria DB 上运行此查询时,它根本没有返回任何结果。 好像 LEFT JOIN 是 INNER JOIN。
我已经用 700 种不同的方式编写了这个查询,但没有任何帮助。我检查了 sql_mode,它在两个数据库上都设置为 ''....任何想法为什么它适用于一个而不是另一个??
【问题讨论】:
-
NULL 永远不等于任何东西,包括它自己。你的 SQL 没有意义。
-
select * from inventory.home_picture_types hpt left join inventory.home_pictures hp on hp.home_picture_type_id = hpt.id where hp.id='';试试这个。 -
它应该返回没有匹配 hpt.id 和 hp.home_picture_type 的行,对吗?我试图找到他们不匹配的地方,这只会返回类似:tinypic.com/r/243pzti/9
-
你的建议没有返回任何内容,就像 = NULL 一样,但我一开始并没有尝试过..
-
你确定数据库有相同的数据?我没有发现您的查询有任何问题...
标签: mysql centos where mariadb isnull