“不喜欢”在 SQL 查询中
为什么这个简单的查询会返回“ORA-00936:缺少表达式”(正如您所知,数据库是Oracle):
SELECT * FROM transactions WHERE id NOT LIKE '1%' AND NOT LIKE '2%'
我觉得很傻,但我做错了什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您错过了第二个
NOT LIKE
中的字段名称id
。尝试:where 子句中的
AND
连接 2 个完整条件表达式,例如id NOT LIKE '1%'
并且不能用于列出 id 为的多个值‘不喜欢’。You have missed out the field name
id
in the secondNOT LIKE
. Try:The
AND
in the where clause joins 2 full condition expressions such asid NOT LIKE '1%'
and can't be used to list multiple values that the id is 'not like'.您需要在两个表达式中指定列。
You need to specify the column in both expressions.
你在 NOT 之前错过了 id;它需要被指定。
You've missed the id out before the NOT; it needs to be specified.
在“AND”和“OR”之后,QUERY 已经忘记了它的全部内容。
我也不知道它是关于任何 SQL/编程语言的。
if(某物等于“X”或某物等于“Y”)
不像“A%”的列并且不像“B%”的列
After "AND" and after "OR" the QUERY has forgotten what it is all about.
I would also not know that it is about in any SQL / programming language.
if(SOMETHING equals "X" or SOMETHING equals "Y")
COLUMN NOT LIKE "A%" AND COLUMN NOT LIKE "B%"