SQL查询中的"NOT LIKE" [英] 'NOT LIKE' in an SQL query
本文介绍了SQL查询中的"NOT LIKE"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这个简单的查询为什么会返回"ORA-00936:缺少表达式"(您可以说数据库是Oracle):
Why does this simple query return 'ORA-00936: missing expression' (the database is Oracle as you can tell):
SELECT * FROM transactions WHERE id NOT LIKE '1%' AND NOT LIKE '2%'
我觉得很傻,但是我在做什么错了?
I feel silly, but what am I doing wrong?
推荐答案
您错过了第二个NOT LIKE
中的字段名称id
.试试:
You have missed out the field name id
in the second NOT LIKE
. Try:
SELECT * FROM transactions WHERE id NOT LIKE '1%' AND id NOT LIKE '2%'
where子句中的AND
连接2个全条件表达式,例如id NOT LIKE '1%'
,并且不能用于列出id为不喜欢"的多个值.
The AND
in the where clause joins 2 full condition expressions such as id NOT LIKE '1%'
and can't be used to list multiple values that the id is 'not like'.
这篇关于SQL查询中的"NOT LIKE"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文