Query where foreign key column can be NULL
问题 I want to get data if orgid = 2 or if there is no row at all for the uid . orgid is an integer . The closest thing I could think of is to do IS NULL but I'm not getting data for the uid that doesn't have an orgid row. Any idea? select u.uid,u.fname,u.lname from u inner join u_org on u.uid = u_org.uid inner join login on u.uid = login.uid where u_org.orgid=2 or u_org.orgid is NULL and login.access != 4; Basically the OR is if u_org.orgid row doesn't exist. 回答1: If there is "no row at all for