Inserting a Zero instead of NULL while performing LEFT OUTER JOIN in MYSQL

后端 未结 3 1565
悲&欢浪女
悲&欢浪女 2021-01-11 11:06

Is there a way to insert a zero instead of NULL while performing LEFT OUTER JOIN on two tables?

Suppose I have a query like this:

SELECT * FROM
(SEL         


        
相关标签:
3条回答
  • 2021-01-11 11:45

    something 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
    
    0 讨论(0)
  • 2021-01-11 11:55
    CASE WHEN a.fieldname IS NULL 
           THEN 0
           ELSE a.fieldname
    END AS fieldname
    
    0 讨论(0)
  • 2021-01-11 12:02

    use ISNULL(field, 0) this will insert zero if the field is NULL

    0 讨论(0)
提交回复
热议问题