在两个表上执行左外联接时,有没有方法插入一个零而不是null?假设我有这样一个查询:
SELECT * FROM (SELECT uID from Class) T1 LEFT OUTER JOIN (SELECT pID from University) T2 ON T1.uID = T2.pID CASE WHEN T1.uID IS NULL THEN 0 ELSE T1.uID END AS uID`
如果我错了就纠正我
798qvoo81#
CASE WHEN a.fieldname IS NULL THEN 0 ELSE a.fieldname END AS fieldname
mbjcgjjk2#
使用 ISNULL(field, 0) 如果字段为空,则将插入零
ISNULL(field, 0)
bogh5gae3#
什么like:-
SELECT * FROM (SELECT ifnull(uID,0) as uID from Class) T1 LEFT OUTER JOIN (SELECT ifnull(pID,0) as pID from University) T2 ON T1.uID = T2.pID
3条答案
按热度按时间798qvoo81#
mbjcgjjk2#
使用
ISNULL(field, 0)
如果字段为空,则将插入零bogh5gae3#
什么like:-