2016-11-30 75 views
0

是他们的任何方式或查询,以防止数据显示,如果有相同的incident_id和我的附加的图像使用SQL:从状态显示防止数据

enter image description here

的pnt_id为NULL。突出显示的数据一定不能显示

是否有可能?如果是这样。谁能帮我。?并提前

+0

http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-询问问题/ 285557#285557 –

+0

@a_horse_with_no_name其PHPMyAdmin(XAMMP) –

+0

@a_horse_with_no_name,如果我可以问吗?你刚刚评论过的链接怎么样? –

回答

2

感谢尝试此查询:

SELECT respond_id, incident_id, pnt_id FROM TBL 
WHERE pnt_id IS NOT NULL 
UNION 
SELECT respond_id, incident_id, pnt_id FROM TBL 
WHERE incident_id in (SELECT distinct(incident_id) 
         FROM TBL 
         GROUP BY incident_id 
         HAVING count(id) = 1); 

联合的第一部分将得到所有的NOT NULL pnt_ids ,第二部分将得到可能为空的所有记录,但走在结果。

联盟合并两个结果排除重复

+0

我在'where子句'中收到错误'未知列'pnt_id' –

+0

您确定发布的列名称是正确的吗? 我用tbl作为表名,因为你没有提供表名 – IvanM

+0

哥们对不起这是现在的错误。 ''having clause''中的未知列'respond_id'..我在表名 –