我有一个关于null值的问题,我有这个代码
SELECT NULL,NULL,username, omschrijving, datum, project ,opdrachtgever ,tijd_van,tijd_tot,TIME_FORMAT(TIMEDIFF(tijd_tot,tijd_van), '%H:%i') as nosearch_diff
FROM uren ur
JOIN projecten AS pr ON pr.project_id = ur.project_id
JOIN user AS us ON us.userid = ur.userid
JOIN opdrachtgever AS og ON pr.opdrachtgever_id = og.opdrachtgever_id
UNION
SELECT materiaal,afdeling,username, omschrijving, datum, project ,opdrachtgever ,tijd_van,tijd_tot,TIME_FORMAT(TIMEDIFF(tijd_tot,tijd_van), '%H:%i') as nosearch_diff
FROM materiaal AS ma
JOIN projecten AS pr ON pr.project_id = ma.project_id
JOIN user AS us ON us.userid = ma.userid
JOIN opdrachtgever AS op ON op.opdrachtgever_id = pr.opdrachtgever_id
JOIN afdeling AS af ON af.afdeling_id = ma.afdeling_id
JOIN materiaalnaam AS mt ON mt.materiaalnaam_id = ma.materiaalnaam_id
查询工作正常,但我有1个问题。第一个查询具有双NULL值,它引用第二个查询materiaal和afdeling 但是,如果我想显示它,它只显示第一个NULL中的afdelingen值和第二个NULL,例如:
让我们说afdeling = Shipping and materiaal Boat。
显示如下:
NULL : Shipping
NULL : Shipping
但我希望它显示如下:
NULL : Shipping
NULL : Boat
是否有人知道如何解决此问题
谢谢, 凯文
答案 0 :(得分:0)
我修复了它我只给它们一个名字的NULL值 例如:
NULL AS materiaal ,NULL AS afdeling
这是解决问题的方法。
谢谢大家!