Summing and comparing with or without parentheses

I have 3 columns which are of type double.

I need to get results where the sum these of 3 columns is more than x.

Maybe a dumb question, which of the following methods is better for this

1) Usually summing: WHERE col1 + col2 + col3 > x

2) Or summing in parentheses: WHERE (col1 + col2 + col3) > x

Or there is absolutely no difference between the two menthods ?

Answers


Your both query has no problem.By operator hierarchies it would be better to use parenthesis method.

MySQL Operator Precedence documentation

Operator precedences are shown in the following list, from highest precedence to the lowest. Operators that are shown together on a line have the same precedence.

INTERVAL
BINARY, COLLATE
!
- (unary minus), ~ (unary bit inversion)
^
*, /, DIV, %, MOD
-, +
<<, >>
&
|
= (comparison), <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN
BETWEEN, CASE, WHEN, THEN, ELSE
NOT
&&, AND
XOR
||, OR
= (assignment), := 
Its better to handle the summarized values among three columns.

WHERE (col1 + col2 + col3) > x


Need Your Help

Passing the UserID to a SelectCommand in DotNetNuke

asp.net dotnetnuke

I am trying to get the users who belong in a specific user role. Under /Admin/SecurityRoles.aspx after clicking

Jenkins- multiple locations SVN. Is it possible to specify the build version

continuous-integration jenkins

I am new to Jenkins CI tool and I want to know if it is possible to specify what build to use when there are several projects, on different SVN locations, dependent on one another. For example, if ...