Reputation: 367
please help me guys!
My code doesn't work :( Where is my error?
SELECT * from dummy_table where `a` + `b` + `c` like '99';
I have empty return although there are some rows where sum of (a,b,c) gives 99.
a is integer while b,c are DOUBLE. Could this lead into an issue?
Upvotes: 1
Views: 66
Reputation: 51993
You should have a mathematical comparison in your WHERE clause
SELECT * FROM dummy_Table WHERE a + b + c = 99
If you are concerned that the double may contain a small precision that you want to disregard when comparing then round the columns with doubles to your preferred precision, for instance 2 decimals.
SELECT * FROM dummy_Table WHERE a + ROUND(b,2) + ROUND(c,2) = 99
Upvotes: 2
Reputation: 46
It looks like you are trying to sum a,b,c as letters not as columns. Try removing the single quotes.
Is '99' the full match? You could also try '%99%' if it makes sense in your case.
Upvotes: -1