Hi all
For ex am having the table student with fields student name and marks...Where as name is of the type string and marks float value....and having the records
Studentname Marks
aaa 10.5
bbb 15.3
Now am writing the query - Select * from table where Marks=10.5;
But while executing this query am getting 0 results....What can i do...Is there any way to solve this problem....Other than '=' operator for all (>,<,like,In)am getting the result...Please suggest me
7 4792
Hi all
For ex am having the table student with fields student name and marks...Where as name is of the type string and marks float value....and having the records
Studentname Marks
aaa 10.5
bbb 15.3
Now am writing the query Select * from table where Marks=10.5;
But while executing this query am getting 0 results....What can i do...Is there any way to solve this problem....Other than '=' operator for all (>,<,like,In)am getting the result...Please suggest me
try this: -
-
SELECT * from table WHERE ROUND(marks) = ROUND(10.5);
-
-
try this: -
-
SELECT * from table WHERE ROUND(marks) = ROUND(10.5);
-
-
i think this may not be correct ...Why because we are using the round function means we are making that Float value as integer...I don't want to compare two integers i want to compare float values...because in my application even 0.4 value makes a lot difference...please tell me the reason for this and what to do...
Hi sijayreddy,
Welcome to TSDN!!!
Kindly use CODE tags when posting source code.
What is the data type of 'Marks'? I know you have told above, but I want to make sure. There is no problem with your query. Or you can try this - SELECT * FROM table WHERE Marks>=10.5 AND Marks<=10.5;
Hi sijayreddy,
Welcome to TSDN!!!
Kindly use CODE tags when posting source code.
What is the data type of 'Marks'? I know you have told above, but I want to make sure. There is no problem with your query. Or you can try this - SELECT * FROM table WHERE Marks>=10.5 AND Marks<=10.5;
Hi
Hear am giving all the details how i created the table and inserted the data and the query for retrieving the data -
create table ex(name char,mark float,total float);
-
insert into ex values ('a',10.5,55.5);
-
insert into ex values ('b',1156.66,5656.65);
-
select * from ex where mark=10.5;
-
select * from ex where mark=1156.66 ;
for the first query i.e Select * from ex where mark=10.5... getting the correct result but for the second select query select * from ex where mark=1156.66 query browser is returning ZERO result....
Kindly tell me the reason what is the reason for this and how to resolve the problem
Change data type to DOUBLE using the below query - ALTER TABLE `ex` CHANGE `mark` `mark` DOUBLE( 14, 2 ) NULL DEFAULT NULL
Now test your query - SELECT * FROM ex WHERE mark=1156.66 ;
FLOAT values are not stored as exact values inside computer architecture.
Change data type to DOUBLE using the below query - ALTER TABLE `ex` CHANGE `mark` `mark` DOUBLE( 14, 2 ) NULL DEFAULT NULL
Now test your query - SELECT * FROM ex WHERE mark=1156.66 ;
FLOAT values are not stored as exact values inside computer architecture.
Thank u mwasif...it is working now...
You are welcome. Postback whenever you need help.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jonathan Fielder |
last post by:
Hi,
I have a 32 bit integer value and I wish to find the single precision
floating point value that is closest to but less than or equal to the
integer. I also have a similar case where I need...
|
by: Andy |
last post by:
Hi,
I don't know if this is the correct group to post this, but
when I multiply a huge floating point value by a really
small (non-zero) floating point value, I get 0 (zero) for the result.
This...
|
by: ziller |
last post by:
Why is it that FLT_DIG (from <float.h>) is 6 while DBL_DIB is 15?
Doing the math, the mantissa for floats is 24 bits = 2^24-1 max value
= 16,777,215.0f. Anything 8-digit odd # greater than that...
|
by: Gerald Lafreniere |
last post by:
{
float F=123.456000;
F*=1000; // Actually I used a for loop F*=10 three times.
printf("%f\n", F);
}
This will produce something like 123456.00XXXX, where XXXX are garbage
digits. Why...
|
by: Neils Christoffersen |
last post by:
Hey all,
I wrote on Friday asking for some help moving a common subclass field up
to the base class (original post and followup included below). This
entails storing whole numbers inside float...
|
by: karthi |
last post by:
hi,
I need user defined function that converts string to float in c.
since the library function atof and strtod occupies large space in
my processor memory I can't use it in my code.
regards,...
|
by: joesfer |
last post by:
I'm trying to develop a graphical user interface for a renderer i've
got written in an unmanaged C++ DLL with C#. During the rendering
process, several images are sent to a delegate as float*...
|
by: Peter Knörrich |
last post by:
Hello,
I've found another inconsistency, and looking through the
list archives I can find mentions of funky stuff like
print float('inf')
giving
Infanity
|
by: Lie |
last post by:
I've noticed some oddly inconsistent behavior with int and float:
Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23)
on linux2
-345
works, but
Traceback (most recent call last):
File...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |