1

我尝试了下面的命令。这是 a DataSourceof aGridView并且写在我的.aspx页面上,所以我不能使用像""or之类的字符''。这段代码不会给我任何回报。我还尝试将 (string.empty, "" and 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不可能null)但我只是不知道该怎么做,所以我尝试了所有想到的东西。

4

2 回答 2

0

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

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

并使用WHERE您将其中一个文件INNER JOINNULL

WHERE ch.responsavel IS NULL

INNER JOIN连接不为空的字段。所以这两种说法相互除外。

于 2013-01-23T13:41:57.933 回答
0

I found out the problem, it was:

I'm using INNER JOINS and as @valex told me:

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

The solution was change the INNER JOIN for LEFT JOIN and worked like a charm !

Thanks everyone !

于 2013-01-23T18:25:24.890 回答