具有多个Or和And条件的SQL语句(SQL statement with multiple Or and And conditions)
我有一个问题,我现在无法找到解决方案。
这是一个我的类型的sql语句示例:
SELECT * FROM table
WHERE ((id IS '2' AND name IS 'foo' ) OR
(is IS '3' AND name IS 'bar' ) OR
(id IS '4' AND name IS 'foobar'))
由于任何原因它只返回一行但它应该返回所有3行。
编辑:
我发现了我的错误,这只不过是我的愚蠢。 很抱歉给您带来不便.....
在我的真实陈述中所有ORd条款相等,我无法看到森林的树..
i have a problem i cant find the solution right now.
here is an example sql statement of my kind:
SELECT * FROM table
WHERE ((id IS '2' AND name IS 'foo' ) OR
(is IS '3' AND name IS 'bar' ) OR
(id IS '4' AND name IS 'foobar'))
for any reason it only returns one row but it should return all 3 rows.
EDIT:
I found my error and it was nothing but stupidness of mine. sorry for your inconvenience.....
in my real statement all ORd clauses where equal and i couldnt see the tree for the forest..
原文:https://stackoverflow.com/questions/20059918
2020-02-16 21:31
满意答案
我几乎都说问题在于您的数据,但您没有给我们足够的信息。 检查你的桌子,确保你正确查询。 根据您的陈述,您的查询应该有效(带有更正的修复)。 看看这里的sqlfiddle linke。
I'd almost say the problem is in your data, but you're not giving us enough info. Check your table and make sure you're querying appropriately. Based on your statement, your query should work (with corrected fixes). Look at the sqlfiddle linke here.
相关问答
你可以使用: SELECT avg(cast(meantempi as integer))
FROM weather_data
WHERE cast (strftime('%w', date) as integer) IN (0, 6)
You can use in: SELECT avg(cast(meantempi as integer))
FROM weather_data
WHERE cast (strftime('%w', date) as integer) IN (0, 6)
您需要使用功能 ,如: {{ if and .condition1 .condition2 }}
{{ end }}
以下是一个工作示例: https : //play.golang.org/p/g_itE5ggCM You need to use function and, like: {{ if and .condition1 .condition2 }}
{{ end }}
Here's an...
浮点异常 - 这意味着存在算术错误。 看起来你正试图用j停止循环,但你实际上正在做的是永远继续循环(因为一旦你得到j == 1 or条件总是为真 )。 然后发生的是你将所有Integer值循环回0并获得异常。 我认为你想做的是: for (i = 2; (i < number); i++)
{
if (number%i==0)
{
j = 1;
break;
}
}
floating point exception - This means...
我怀疑你想要这样的东西: where budgetid = @budgetid or
(@budgetid = 7 and budgetid in (7, 8, 10)) or
(@budgetid = 8 and budgetid = 6)
您的查询失败,因为对于除7或8以外的@budgetid所有值, case返回NULL - 将其视为false。 I suspect that you want something like this: where budgetid ...
这可以使用ifelse完成 with(dat, ifelse(x < 0.15 & dif <0, 3, ifelse(x > 0.15 & dif < 0, 2, 1)))
要么 with(dat, as.numeric(factor(1+4*(x < 0.15 & dif < 0) + 2*(x>=0.15 & dif < 0))))
This can be done using either ifelse with(dat, ifelse(x < 0.15 & dif <0, 3, if...
如果我明白你的任务正确地执行下面的代码应该做的工作: --drop table real;
--drop table stag;
create table real (
id NUMBER,
col1 NUMBER,
col2 VARCHAR(10)
);
create table stag (
id NUMBER,
col1 NUMBER,
col2 VARCHAR(10)
);
insert into real values (1, 1, 'a');
insert...
您可以在SET子句中使用CASE条件 UPDATE table1
SET table1.column1 = CASE WHEN THEN value1 WHEN THEN value2 END,
table1.column2 = CASE WHEN THEN value1 WHEN THEN value2 END
.
.
WHERE
.
.
编辑 :要使用多个表进行更新,您可以根据常见条件使用...
您没有使用常规if语句,您正在使用可选绑定,并且您无法将绑定与对绑定值的检查结合起来。 你可以把它分解成这样的东西。 if let name = json["resource"]["fields"]["name"].stringValue {
if name.hasPrefix("/") {
// stuff
}
}
编辑 :在Swift 1.2中看起来已经发生了变化。 根据发行说明,现在可以为if let添加额外条件,而let语句: “if let”构造已经扩展...
要做的事: 由于您在同一个表上放置了两个条件,我假设您需要查找2015年1月1日之后存在于终端表中的所有终端,并且也在AuditTerminal中。 所以把它们放在单个查询中。 select count(*)
from AuditTerminal(nolock)
where TerminalID IN
(Select TerminalID from Terminal where LastChangeDate>= '2015-01-01')
我们也可以使用更有意义的JOI...
我几乎都说问题在于您的数据,但您没有给我们足够的信息。 检查你的桌子,确保你正确查询。 根据您的陈述,您的查询应该有效(带有更正的修复)。 看看这里的sqlfiddle linke。 I'd almost say the problem is in your data, but you're not giving us enough info. Check your table and make sure you're querying appropriately. Based on your s...
相关文章
在SQL中包含特殊字符或SQL的关键字(如:' or 1 or ')时Statement将出现不可预料
...
小弟最近做个练习 在表格分页的时候 有个很帅的分页工具栏 最右边是一个刷新的按钮 调了下 发现他是
...
每天24小时,现在数据表里只有7,8,9点有数据 怎么得到24条数据?? 其他的没数据的时间都是0
...
Hibernate在那个方法里将HQL转成普通SQL语句并执行的? 问题补充: 小弟不才,根据各位
...
目前的情况是这样的 1,我有一个表,里面有一个ID,名字,昵称 2,我现在想写一个SQL语句,把名
...
简单语句:每行至多包含一条语句;复合语句:复合语句是包含在大括号中的语句序列,形如"{ 语句 }";返
...
SELECT a.type, b.postnature, b.compcode FROM 职工岗位管
...
select * from dbo.tbGoodsInfo where (id in (select
...
1.表结构如下: 1991 1.1 21 1991 1.2 22 1991 1.3 23 19
...
最新问答
更新:从1.4开始,Spring Boot支持Thymeleaf 3,但版本2仍然是默认设置。 有关如何使用Thymeleaf 3的详细信息,请参阅文档 。 Spring Boot 1.3及更早版本不支持Thymeleaf 3.您需要为Thymeleaf禁用Boot的自动配置并手动配置它。 您可以使用@SpringBootApplication上的exclude属性禁用自动配置: @SpringBootApplication(exclude=org.springframework.boot.au
不,这是不可能的。 您从GCM获得的注册ID与特定设备上的应用程序相关联。 如果您尝试从服务器执行注册,GCM如何知道识别注册ID所绑定的设备? No, it's not possible. The Registration ID that you get from GCM is tied to an application on a specific device. If you would try to perform the registration from the server, ho
是的,当使用kafka-topics.sh工具删除主题时,您可以使用类似于正则表达式的表达式: 例如,要删除以giorgos-开头的所有主题: ./bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic giorgos-.* 使用管理API,您也可以一次删除多个主题,请参阅AdminClient.deleteTopics Yes you can use regex-like expressions when deletin
摆脱“classpath”前缀: .getBundle("/properties/custom") “classpath”前缀不是一个标准,它是由一些像spring这样的框架定义的。 Get rid of the "classpath" prefix.: .getBundle("/properties/custom") The "classpath" prefix is not a standard, it is defined by some frameworks like spring.
溢出:隐藏。 在下面的CSS中添加: #block-brainstorm-theme-main-menu 一旦你从这里删除溢出属性,并删除显示:无。 从 #block-brainstorm-theme-main-menu ul ul 子菜单将显示。 但是你必须在css和js上进行适当的外观和感觉。 相反,我建议为此使用一些jquery.Also也可以使用像Nice菜单或Superfish菜单一样的模块。 让我知道我是否可以帮助你。 Overflow: hidden. is added in
1)您在java进程中看到的变量是从您启动java进程的进程继承的变量。 即,如果从shell启动它,它应该具有与shell相同的变量。 您需要在启动Java应用程序之前调查实际设置的变量,以及为什么未在该上下文中设置您期望的变量。 要回答第2部分,是的,将在ProcessBuilder.environment()使用环境启动该过程。 您可以简单地将事物添加到ProcessBuilder.environment()返回的映射中,这将扩展运行时环境: ProcessBuilder pb = new
(('sssss',), ('root',)) 和 ('sssss', 'root') 表示的东西不一样。 'sssss', 有逗号表示的是 tuple, 而'sssss'只是字符串,所以(('sssss',), ('root',)) 是tuple 组成的tuple,('sssss', 'root') 是字符串组成的tuple。 (('sssss',), ('root',)) 转成 (('sssss'), ('root')) t=(('sssss',), ('root',)) result=(j
箱形图不绘制均值或方差。 您实际上需要完整的排名数据来绘制正确的箱线图,因为数量是中位数,四分位数和1.5倍IRQ内的关闭数据点的实际值加上超出该范围的所有数据点(异常值)。 对于大型数据集来说,这通常不是一个好主意(因为根据定义,您有数百万个异常值)。 也就是说,您可以按照您想要的方式生成基本摘要,并使用bxp绘制它们 - 请参阅R中的?bxp 。如果不是上述内容,请确保说明您正在绘制的数量。 Boxplots do not plot mean or variance. You actuall
看起来hadoop正在使用jets3t库进行S3访问。 您可以使用此博客中描述的配置来访问eucalyptus,但请注意,对于版本4,路径为“/ services / objectstorage”而不是“/ services / Walrus”。 It looks like hadoop is using the jets3t library for S3 access. You might be able to use the configuration described in this b
您所看到的是内存泄漏 - AsyncTask保留对其声明的Activity的引用,并阻止Android运行时垃圾收集它。 回答你的问题: 无法使用命令停止AsyncTask。 您可以请求在onDestroy()中取消它,但它仍然只在执行了doInBackground()方法后执行,在您的情况下将是Runnable。 您可以选择使用静态嵌套的AsyncTask,它不会保存对它所驻留的Activity的引用 - 需要注意的是,您将无法从Activity中引用任何内容,但这对您的案例来说不应该是一个大