Home > Database > Mysql Tutorial > sql实现多字段求和并查询

sql实现多字段求和并查询

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:23:01
Original
5022 people have browsed it

下面就sql多字段求和并作为sql查询条件的方法进行了说明,供您参考,希望对您学习sql查询方面有所帮助。 做一个字段求和的小sql查询,查询一个表中,字段1,字段2和字段3之和大于0的结果,故写了如下的SQL语句。 有一点要注意的是,在Where字句中,不能有自

下面就sql多字段求和并作为sql查询条件的方法进行了说明,供您参考,希望对您学习sql查询方面有所帮助。

做一个字段求和的小sql查询,查询一个表中,字段1,字段2和字段3之和大于0的结果,故写了如下的SQL语句。

有一点要注意的是,在Where字句中,,不能有自己运算后得到的字段。

sqlstr = "SELECT W.ID,W.Weather,greenColor,(SELECT redColor+greenColor+blueColor FROM Weather N WHERE N.ID = W.ID) AS AllValue FROM Weather W WHERE (SELECT redColor+greenColor+blueColor FROM Weather N WHERE N.ID = W.ID)>0 ORDER BY ID";

即如下的SQL语句是行不通的,说是"至少一个参数没有被指定值"。

sqlstr = "SELECT W.ID,W.Weather,greenColor,(SELECT redColor+greenColor+blueColor FROM Weather N WHERE N.ID = W.ID) AS AllValue FROM Weather W WHERE AllValue >0 ORDER BY ID";

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
ubuntu mongodb 出现 exception: connect failed
From 1970-01-01 08:00:00
0
0
0
An error occurred
From 1970-01-01 08:00:00
0
0
0
Why does clicking login jump to hello world?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template