以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]SQL问题,如果数据库中字段值为空,则无法读取出来 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=118659) |
-- 作者:xndd -- 发布时间:2018/5/8 14:47:00 -- [求助]SQL问题,如果数据库中字段值为空,则无法读取出来 数据库在第一次插入数据后,两个字段值是为空的,因为是流程到第二步第三步才往里面添加数据的,但是这样,就无法select出数据来了: S ELECT d.Name AS \'填写部门\', c.Name AS \'填写人\', a.WriteDate AS \'填写时间\', a.LSH AS \'流水号\', e.ZMC AS \'值类别\', a.jymc AS \'检验名称\',a.PIHAO AS \'批号\', a.qysj AS \'取样时间\', f.Name AS \'取样人\', a.SFLY AS \'是否留样\', a.LYBH AS \'留样编号\', a.COA AS \'成品COA编号\', a.JYBZYJ AS \'检验标准依据\', a.CSJG AS \'测试结果\', g.DW AS \'单位\', a.jd AS \'校对\', h.Name AS \'校对人\', a.JDSJ AS \'校对时间\', a.SH AS \'审核\', i.Name AS \'审核人\', a.SHSJ AS \'审核时间\' F ROM dbo.T_PG_PZJYB a JOIN tXTDM b ON a.JYLB = b.IBM JOIN dbo.tUser c ON a.WriteMan = c.ID JOIN dbo.lbOrganization d ON a.WriteDept = d.ID JOIN T_PZ_ZLBB e ON a.ZLB = e.ID JOIN tuser f ON a.qyr = f.ID JOIN T_PZ_JLDWB g ON a.dw = g.ID JOIN dbo.tUser h ON a.jdr = h.ID JOIN dbo.tUser i ON a.SHR = i.ID W HERE B.FLDM = \'JYLB\' AND a.JYLB = 2 |
-- 作者:xndd -- 发布时间:2018/5/8 14:48:00 -- 插入图片 [此贴子已经被作者于2018/5/8 14:48:04编辑过]
|
-- 作者:xndd -- 发布时间:2018/5/8 14:49:00 -- 就是因为jdr 和 sdr 这两个字段(校对人、审核人),一开始为null,但是关联表都是有值的,所以选不出吧? 我sql语句写的有问题吧
|
-- 作者:有点蓝 -- 发布时间:2018/5/8 15:18:00 -- left JOIN dbo.tUser h ON a.jdr = h.ID left JOIN dbo.tUser i ON a.SHR = i.ID |
-- 作者:xndd -- 发布时间:2018/5/8 15:45:00 -- 以下是引用有点蓝在2018/5/8 15:18:00的发言: left JOIN dbo.tUser h ON a.jdr = h.ID left JOIN dbo.tUser i ON a.SHR = i.ID 看懂了,唉,左关联啊。
[此贴子已经被作者于2018/5/8 15:45:48编辑过]
|