MySQL wrongly selecting decimal values
I have a table with decimal values.
start_value decimal(10,2) | end_value decimal(10,2)
This is my MySQL query.
SELECT * FROM my_table WHERE start_value >= '1.05' && end_value <= '1.05'
Above query produce zero results but in my database, there is a value 1.00 – 1.49
And if I change the query to just select the first value like below
SELECT * FROM my_table WHERE start_value >= '1.05'
MySql is displaying a wrong result. It will display 1.5 and 1.99 when it should be displaying 1.00 – 1.49
Can anyone tell me what im doing wrong here? Appreciate all your answers.
mysql mysqli
|
show 5 more comments
I have a table with decimal values.
start_value decimal(10,2) | end_value decimal(10,2)
This is my MySQL query.
SELECT * FROM my_table WHERE start_value >= '1.05' && end_value <= '1.05'
Above query produce zero results but in my database, there is a value 1.00 – 1.49
And if I change the query to just select the first value like below
SELECT * FROM my_table WHERE start_value >= '1.05'
MySql is displaying a wrong result. It will display 1.5 and 1.99 when it should be displaying 1.00 – 1.49
Can anyone tell me what im doing wrong here? Appreciate all your answers.
mysql mysqli
Please setup a DB fiddle / SQL fiddle with the relevant sample data and showcasing your exact issue.
– Madhur Bhaiya
Nov 20 '18 at 17:35
2
You realize that1.00 >= 1.05
is false, right?
– Bill Karwin
Nov 20 '18 at 17:35
start_value decimal(10,2) | end_value decimal(10,2)
are these values mean something?
– Akhila Madari
Nov 20 '18 at 17:37
do we have&&
in sql? I cannot recall stackoverflow.com/questions/4105658/…
– Akhila Madari
Nov 20 '18 at 17:39
@AkhilaMadari decimal(10,2) is the datatype in my table.
– ally
Nov 20 '18 at 17:40
|
show 5 more comments
I have a table with decimal values.
start_value decimal(10,2) | end_value decimal(10,2)
This is my MySQL query.
SELECT * FROM my_table WHERE start_value >= '1.05' && end_value <= '1.05'
Above query produce zero results but in my database, there is a value 1.00 – 1.49
And if I change the query to just select the first value like below
SELECT * FROM my_table WHERE start_value >= '1.05'
MySql is displaying a wrong result. It will display 1.5 and 1.99 when it should be displaying 1.00 – 1.49
Can anyone tell me what im doing wrong here? Appreciate all your answers.
mysql mysqli
I have a table with decimal values.
start_value decimal(10,2) | end_value decimal(10,2)
This is my MySQL query.
SELECT * FROM my_table WHERE start_value >= '1.05' && end_value <= '1.05'
Above query produce zero results but in my database, there is a value 1.00 – 1.49
And if I change the query to just select the first value like below
SELECT * FROM my_table WHERE start_value >= '1.05'
MySql is displaying a wrong result. It will display 1.5 and 1.99 when it should be displaying 1.00 – 1.49
Can anyone tell me what im doing wrong here? Appreciate all your answers.
mysql mysqli
mysql mysqli
edited Nov 20 '18 at 17:32


Madhur Bhaiya
19.6k62236
19.6k62236
asked Nov 20 '18 at 17:27


allyally
1
1
Please setup a DB fiddle / SQL fiddle with the relevant sample data and showcasing your exact issue.
– Madhur Bhaiya
Nov 20 '18 at 17:35
2
You realize that1.00 >= 1.05
is false, right?
– Bill Karwin
Nov 20 '18 at 17:35
start_value decimal(10,2) | end_value decimal(10,2)
are these values mean something?
– Akhila Madari
Nov 20 '18 at 17:37
do we have&&
in sql? I cannot recall stackoverflow.com/questions/4105658/…
– Akhila Madari
Nov 20 '18 at 17:39
@AkhilaMadari decimal(10,2) is the datatype in my table.
– ally
Nov 20 '18 at 17:40
|
show 5 more comments
Please setup a DB fiddle / SQL fiddle with the relevant sample data and showcasing your exact issue.
– Madhur Bhaiya
Nov 20 '18 at 17:35
2
You realize that1.00 >= 1.05
is false, right?
– Bill Karwin
Nov 20 '18 at 17:35
start_value decimal(10,2) | end_value decimal(10,2)
are these values mean something?
– Akhila Madari
Nov 20 '18 at 17:37
do we have&&
in sql? I cannot recall stackoverflow.com/questions/4105658/…
– Akhila Madari
Nov 20 '18 at 17:39
@AkhilaMadari decimal(10,2) is the datatype in my table.
– ally
Nov 20 '18 at 17:40
Please setup a DB fiddle / SQL fiddle with the relevant sample data and showcasing your exact issue.
– Madhur Bhaiya
Nov 20 '18 at 17:35
Please setup a DB fiddle / SQL fiddle with the relevant sample data and showcasing your exact issue.
– Madhur Bhaiya
Nov 20 '18 at 17:35
2
2
You realize that
1.00 >= 1.05
is false, right?– Bill Karwin
Nov 20 '18 at 17:35
You realize that
1.00 >= 1.05
is false, right?– Bill Karwin
Nov 20 '18 at 17:35
start_value decimal(10,2) | end_value decimal(10,2)
are these values mean something?– Akhila Madari
Nov 20 '18 at 17:37
start_value decimal(10,2) | end_value decimal(10,2)
are these values mean something?– Akhila Madari
Nov 20 '18 at 17:37
do we have
&&
in sql? I cannot recall stackoverflow.com/questions/4105658/…– Akhila Madari
Nov 20 '18 at 17:39
do we have
&&
in sql? I cannot recall stackoverflow.com/questions/4105658/…– Akhila Madari
Nov 20 '18 at 17:39
@AkhilaMadari decimal(10,2) is the datatype in my table.
– ally
Nov 20 '18 at 17:40
@AkhilaMadari decimal(10,2) is the datatype in my table.
– ally
Nov 20 '18 at 17:40
|
show 5 more comments
1 Answer
1
active
oldest
votes
Here when you are providing the range you need to provide your start and end value correctly.For the values you have given it can be queried as follows
SELECT * FROM my_table WHERE start_value >= '1.00' and end_value <= '1.50'
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398386%2fmysql-wrongly-selecting-decimal-values%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here when you are providing the range you need to provide your start and end value correctly.For the values you have given it can be queried as follows
SELECT * FROM my_table WHERE start_value >= '1.00' and end_value <= '1.50'
add a comment |
Here when you are providing the range you need to provide your start and end value correctly.For the values you have given it can be queried as follows
SELECT * FROM my_table WHERE start_value >= '1.00' and end_value <= '1.50'
add a comment |
Here when you are providing the range you need to provide your start and end value correctly.For the values you have given it can be queried as follows
SELECT * FROM my_table WHERE start_value >= '1.00' and end_value <= '1.50'
Here when you are providing the range you need to provide your start and end value correctly.For the values you have given it can be queried as follows
SELECT * FROM my_table WHERE start_value >= '1.00' and end_value <= '1.50'
edited Jan 10 at 14:14
answered Nov 20 '18 at 17:36


Akhila MadariAkhila Madari
1,187718
1,187718
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398386%2fmysql-wrongly-selecting-decimal-values%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please setup a DB fiddle / SQL fiddle with the relevant sample data and showcasing your exact issue.
– Madhur Bhaiya
Nov 20 '18 at 17:35
2
You realize that
1.00 >= 1.05
is false, right?– Bill Karwin
Nov 20 '18 at 17:35
start_value decimal(10,2) | end_value decimal(10,2)
are these values mean something?– Akhila Madari
Nov 20 '18 at 17:37
do we have
&&
in sql? I cannot recall stackoverflow.com/questions/4105658/…– Akhila Madari
Nov 20 '18 at 17:39
@AkhilaMadari decimal(10,2) is the datatype in my table.
– ally
Nov 20 '18 at 17:40