mysql左,右连接不返回空值

mysql左,右连接不返回空值

问题描述:

sql code:

SELECT * from propertyfield as pf 
RIGHT JOIN property as p 
ON (pf.pfid = p.propID)

not return null values

or

SELECT * from propertyfield as pf 
RIGHT JOIN property as p 
ON (pf.pfid = p.propID) 
where p.propID is null

not return null values

sql code: strong> p>

   SELECT * from propertyfield as pf 
RIGHT JOIN属性为p 
ON(pf.pfid = p.propID)
  code>  pre> 
 
 

不返回空值 p>

或 strong> p>

  SELECT * from propertyfield as pf 
RIGHT JOIN属性为p 
ON(pf.pfid = p.propID)  
其中p.propID为null 
  code>  pre> 
 
 

不返回空值 p> div>

Try this : Use LEFT JOIN

SELECT * from propertyfield as pf 
LEFT JOIN property as p 
ON (pf.pfid = p.propID) 

From your question, It says that p.propID has null values. So let the propertyfield be your left tabe, which gives all data from it. and property be your right table, which gives the corresponding values or null if no values.