搜索表上的空字段

时间:2013-01-23 12:28:51

标签: asp.net mysql gridview

我尝试了下面的命令。它是DataSource的{​​{1}},它写在我的GridView页面上,因此我无法使用.aspx""等字符。这段代码不会给我任何回报。我还尝试传递(string.empty,“”和null)作为''中的参数。什么都行不通,我不知道还能做什么...

codebehind

SelectCommand="SELECT ch.id, sit.descricao as situacao, resp.responsavel, ch.dt_cadastro, ch.previsao_termino, func.descricao as funcionalidade, proj.descricao as projeto ,pr.id as prid, pr.prioridade, clb.clube FROM chamados AS ch INNER JOIN prioridades as pr ON ch.prioridade = pr.id INNER JOIN clubes as clb ON ch.clube = clb.id INNER JOIN responsaveis as resp ON ch.responsavel = resp.id INNER JOIN situacoes as sit ON ch.situacao = sit.id INNER JOIN projetos as proj ON ch.projeto = proj.id INNER JOIN funcionalidades as func ON ch.funcionalidade = func.id WHERE ch.responsavel IS NULL" 我希望将Obs:字段过滤为null字段。 (我知道int32不能int32)但我只是不知道该怎么做,所以我尝试了所想到的一切。

2 个答案:

答案 0 :(得分:0)

此查询将始终不返回任何结果,因为您在此语句中使用INNER JOIN

INNER JOIN responsaveis as resp ON ch.responsavel = resp.id

并使用WHERE状态,将INNER JOIN个文件中的一个与NULL进行比较

WHERE ch.responsavel IS NULL

INNER JOIN加入 ONLY 字段,这些字段为NOT NULL。所以这两个声明除了彼此之外。

答案 1 :(得分:0)

我发现了问题,原因是:

我正在使用INNER JOINS,而@valex告诉我:

The INNER JOIN joins ONLY fields which are NOT NULL. So these two statement except each other.

解决方案是更改INNER JOIN的{​​{1}}并且像魅力一样工作!

谢谢大家!