Null的SQL语法? [英] SQL syntax for Null?

查看:128
本文介绍了Null的SQL语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有区别吗?


A)WHERE(IsNull(qry100.Cat_ID)= True))


- 或 - -


B)在哪里qry100.Cat_ID是空的


我在想A更好,因为它不那么含糊(?)


感谢你对此的看法... thx

Is there a difference?

A) WHERE (IsNull(qry100.Cat_ID)=True))

--or--

B) WHERE qry100.Cat_ID Is Null

I''m thinking A is better because it is less ambiguous (?)

appreciate your thoughts on this... thx

推荐答案

(B)应该是表示:

WHERE qry100.Cat_ID为空

由JET评估,所以它可以利用

场上的任何索引。


IsNull()如果是VBA函数。这意味着JET必须在每一行上将表达式传递给VBA

,然后将返回值与True进行比较。


避免在不需要的地方使用VBA函数如果你需要这样做,也可以更容易地增加你的应用程序。


-

Allen Browne - 微软MVP。西澳大利亚州珀斯。

访问用户提示 - http:// allenbrowne.com/tips.html

回复群组,而不是mvps dot org的allenbrowne。


" deko" < DJ **** @ hotmail.com>在消息中写道

新闻:JM ***************** @ newssvr27.news.prodigy.co m ...
(B) should be more efficient.

The expression:
WHERE qry100.Cat_ID Is Null
is evaluated by JET, the query engine in Access, so it can take advantage of
any index on the field.

IsNull() if a VBA function. That means JET has to pass the expression to VBA
on each row and then compare the return value to True.

Avoiding VBA function where they are not needed also makes it easier to
upsize your app if you ever need to do that.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"deko" <dj****@hotmail.com> wrote in message
news:JM*****************@newssvr27.news.prodigy.co m...
有区别吗?

A)WHERE(IsNull(qry100.Cat_ID)= True))

- 或 -

B )在哪里qry100.Cat_ID是空的

我在想A更好,因为它不那么含糊(?)

感谢你对此的看法... thx
Is there a difference?

A) WHERE (IsNull(qry100.Cat_ID)=True))

--or--

B) WHERE qry100.Cat_ID Is Null

I''m thinking A is better because it is less ambiguous (?)

appreciate your thoughts on this... thx



On Sun,2003年10月19日02:39:12 GMT,Allen Browne

< al **** *****@SeeSig.invalid>写道:
On Sun, 19 Oct 2003 02:39:12 GMT, "Allen Browne"
<al*********@SeeSig.invalid> wrote:
(B)应该更有效率。

表达式:
WHERE qry100.Cat_ID是空的
由JET,Access中的查询引擎,因此它可以利用该领域的任何索引。

如果是VBA函数,则为IsNull()。这意味着JET必须在每一行上将表达式传递给VBA
,然后将返回值与True进行比较。

避免使用不需要的VBA函数也可以更容易如果您需要,请升级您的应用。
(B) should be more efficient.

The expression:
WHERE qry100.Cat_ID Is Null
is evaluated by JET, the query engine in Access, so it can take advantage of
any index on the field.

IsNull() if a VBA function. That means JET has to pass the expression to VBA
on each row and then compare the return value to True.

Avoiding VBA function where they are not needed also makes it easier to
upsize your app if you ever need to do that.




此外,没有必要比较返回的函数的结果

a boolean with True或False,因为它已经是布尔值True或False。

此外,在你想要将值与True

进行比较的情况下错误(例如表格控件不知道会导致

问题),你应该总是与False比较,永远不与True比较。这是

,因为从技术上讲,VB或Jet SQL中的任何非零值都是True,但是

False总是为零。所以,总是说= False或<> False,never = True。



Also, it is not necessary to compare the result of a function that returns
a boolean with True or False since it is already a boolean True or False.
Furthermore, in the cases where you -do- want to compare a value with True
or False (such as with a form control where not doing so is known to cause
problems), you should always compare with False, never with True. This is
because, technically, any non-zero value is True in VB or Jet SQL, but a
False is always zero. So, always say =False or <>False, never =True.


很棒的提示!谢谢!


好​​奇......如果我升级到MSDE,我是否必须重新编写所有疑问?


我有一个许多查询使用来自表单上的用户输入(组合框,

或其他)的数据。例如:


SELECT SUM(金额)AS TypeTotal,TxType_ID

FROM tblTxJournal

WHERE(年份([TxDate]) =表格!frmMain!frm3.Form!cbx3Year)和

([TxType_ID] =表格!frmMain!frm3.Form!cbx3TxType)

GROUP BY TxType_ID;


我很快就会准备好去MSDE(主要是为了容纳更多用户),但

这需要很长时间才能继续使用SQL服务器...


" Steve Jorgensen" <无**** @ nospam.nospam>在消息中写道

新闻:8k ******************************** @ 4ax.com ...
great tip! thanks!

just curious... do I have to re-write all my queries if I upsize to MSDE?

I have a lot of queries that use data that comes form user input (combo box,
or whatever) on a form. For example:

SELECT SUM(Amount) AS TypeTotal, TxType_ID
FROM tblTxJournal
WHERE (Year([TxDate])=Forms!frmMain!frm3.Form!cbx3Year) And
([TxType_ID]=Forms!frmMain!frm3.Form!cbx3TxType)
GROUP BY TxType_ID;

I''ll be ready to go to MSDE shortly (mainly to accommodate more users), but
it will be a long time before this needs to go on SQL server...

"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:8k********************************@4ax.com...
On Sun,2003年10月19日02:39:12 GMT,Allen Browne
< al ********* @ SeeSig.invalid>写道:
On Sun, 19 Oct 2003 02:39:12 GMT, "Allen Browne"
<al*********@SeeSig.invalid> wrote:
(B)应该更有效率。

表达式:
WHERE qry100.Cat_ID是空的
由JET,Access中的查询引擎,因此它可以利用
的字段上的任何索引。

IsNull()如果是VBA函数。这意味着JET必须将表达式传递给每行
VBA,然后将返回值与True进行比较。

在不需要VBA功能的地方避免使用它也更容易
如果您需要这样做,请升级您的应用。
(B) should be more efficient.

The expression:
WHERE qry100.Cat_ID Is Null
is evaluated by JET, the query engine in Access, so it can take advantage ofany index on the field.

IsNull() if a VBA function. That means JET has to pass the expression to VBAon each row and then compare the return value to True.

Avoiding VBA function where they are not needed also makes it easier to
upsize your app if you ever need to do that.



此外,没有必要将返回布尔值的函数的结果与True或False进行比较,因为它已经是一个布尔值True或False。
此外,在你想要将值与True
或False进行比较的情况下(例如对于不知道这样做的表单控件)
问题),你应该总是与False比较,永远不与True比较。这是因为从技术上讲,VB或Jet SQL中的任何非零值都是True,但
False始终为零。所以,总是说= False或<> False,never = True。



Also, it is not necessary to compare the result of a function that returns
a boolean with True or False since it is already a boolean True or False.
Furthermore, in the cases where you -do- want to compare a value with True
or False (such as with a form control where not doing so is known to cause
problems), you should always compare with False, never with True. This is
because, technically, any non-zero value is True in VB or Jet SQL, but a
False is always zero. So, always say =False or <>False, never =True.



这篇关于Null的SQL语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆