Should I use != or <> for not equal in T
I have seen SQL
that uses both !=
and <>
for not equal . What is the preferred syntax and why?
I like !=
, because <>
reminds me of Visual Basic
.
Technically they function the same if you're using SQL Server AKA T-SQL. If you're using it in stored procedures there is no performance reason to use one over the other. It then comes down to personal preference. I prefer to use <> as it is ANSI compliant.
You can find links to the various ANSI standards at...
http://en.wikipedia.org/wiki/SQL
Most databases support !=
(popular programming languages) and <>
(ANSI).
Databases that support both !=
and <>
:
!=
and <>
!=
and <>
!=
and <>
!=
and <>
!=
and <>
!=
and <>
!=
and <>
!=
and <>
!=
and <>
Databases that support the ANSI standard operator, exclusively :
<>
<>
'<>'
is from the SQL-92 standard and '!='
is a proprietary T-SQL operator. It's available in other databases as well, but since it isn't standard you have to take it on a case-by-case basis.
In most cases, you'll know what database you're connecting to so this isn't really an issue. At worst you might have to do a search and replace in your SQL.
链接地址: http://www.djcxy.com/p/60522.html上一篇: 来自垂死的多线程进程的核心转储
下一篇: 我应该使用!=还是<>在T中不相等