如何在SQL查询中不应用 [英] how to apply not in sql query
本文介绍了如何在SQL查询中不应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望我的查询能像这样:-
从表名中选择*,其中id!= 10000
我该怎么做.帮我解决这个问题!!!!
在此先感谢
i want my query something to b like this:-
select * from tablename where id != 10000
how i can do this. Help me out in this !!!!!
thanks in advance
推荐答案
您可以通过两种方式进行操作:
You can do it in two ways:
SELECT [columns]<br />
FROM [table]<br />
WHERE ID NOT IN ([value1], [value2])<br />
-OR-<br />
SELECT [columns] FROM [table]<br />
WHERE ID <> ''10000''
选项1
select * from tablename where id <> 10000
选项2
Option 2
select * from tablename where id Not IN (10000)
您可以通过两种方式进行操作:
You can do it in two ways:
SELECT [columns]<br />
FROM [table]<br />
WHERE ID NOT IN ([value])<br />
-OR-<br />
SELECT [columns] FROM [table]<br />
WHERE ID <> [value]
您仍然可以使用!=",但这不是标准的SQL.如果您希望代码具有可移植性,请使用<>反而.除此之外,最好使用<>因为它符合ANSI.
You can still use " != " but it is not standard SQL. If you want your code to be portable, use <> instead. In addition to this, it would be better to use <> as it is ANSI compliant.
这篇关于如何在SQL查询中不应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文