我正在從mysql表中取數據,但它在兩個字段中顯示NULL
爲Status
。我想代替NULL
顯示0
。如何在讀取數據時顯示0而不是NULL我的sql表
這裏是我的查詢:
SELECT ml.GroupID, ml.GroupTitle, ml.GroupDescription, ml.GroupCreatedDateTime, ml.GroupOwnerUserID, ml.ApprovalNeeded, ml.GroupStatus, ml.OrganizationCode, cat.Status
FROM GroupsMaster AS ml
LEFT JOIN UserGroupsMapping cat ON cat.GroupID = ml.GroupID
WHERE ml.OrganizationCode = ?
SELECT ml.GroupID,ml.GroupTitle,ml.GroupDescription,ml.GroupCreatedDateTime,ml.GroupOwnerUserID,ml.ApprovalNeeded,ml.GroupStatus,ml.OrganizationCod e,cat.Status COALESCE(cat.Status,0) FROM GroupsMaster AS ml LEFT JOIN UserGroupsMapping cat ON cat.GroupID = ml.GroupID WHERE ml.OrganizationCode ='ibm' – user2240329
請參閱我的查詢,正如你所說的使用它不起作用 – user2240329
@ user2240329你仍然有一個cat.Status丟失在你的代碼中(和/或缺少逗號)。看到我編輯的答案 –