For one, maybe this should better go to comp.databases.mysql?
On 17.08.21 09:40, Kenny McCormack wrote:
In article <[email protected]>,
Josef Moellers <[email protected]d> wrote:
...
select * from myTable where timestamp > 16xxxxxxxx;
Hm, I have never seen a number "16xxxxxxxx", it just looks strange to
me, even to a German (who swaps "."s and ","s in numbers ;-) )
I am using an actual number (an integer, though, not a "real number" - yes,
I am kidding...). The Xs were just standins.
It is ALWAYS better to be as precise as possible. We just don't know
what you /actually/ mean when you write something. So just write the
EXACT statement you useot are using rather than something that resembles whatever you wrote. I guess you won't tell any secrets if you write the
exact number you are comparing with.
I've found that this always returns true, even when it shouldn't. I can >>> (and have) fix(ed) it by doing:
select * from myTable where timestamp+0 > 16xxxxxxxx;
I gues this tries to fix it from the wrong side. It might work if
"timestamp" is a string, but not if "timestamp" is already a number.
Note sure what you mean by this.
I'm not an SQL expert myself, but in a number of languages and contexts,
adding "0" to a STRING (or multiplying a STRING with a "1") containing a
number converts the STRING into a proper NUMBER which you then can
compare properly.
So, if this were one of these contexts (again: IANASE), adding "0" to
something that is already a NUMBER (rather than a STRING) will do nothing.
Why do you think you MUST compare strings rather than numbers?
I don't. The point is I want them to compare as numbers. Hence the +0.
I'm just pointing out that it "should" work even if they were being compared as strings.
If the above doesn't help: what does your "CREATE TABLE" statement look
like?
Just: CREATE TABLE xxx foo,bar,timestamp;
This does not work. If you want help, please QUOTE the EXACT statement
and not something you think will tell what you actually did.
I tried this:
CREATE TABLE xxx (foo,bar,timestamp);
INSERT INTO xxx (foo,bar,timestamp) VALUES ("abc", "devf", 12345);
SELECT * FROM xxx WHERE timestamp > 10000;
abc|devf|12345
SELECT * FROM xxx WHERE timestamp > 20000;
<no output>
SELECT * FROM xxx WHERE timestamp > "10000";
<no output>
SELECT * FROM xxx WHERE foo > "aaa";
abc|devf|12345
SELECT * FROM xxx WHERE foo > "bbb";
<no output>
INSERT INTO xxx (foo,bar,timestamp) VALUES ("ghi", "jklm", "12345");
SELECT * FROM xxx WHERE timestamp > 10000;
abc|devf|12345
ghi|jklm|12345
SELECT * FROM xxx WHERE timestamp > 20000;
ghi|jklm|12345
SELECT * FROM xxx WHERE timestamp > "10000";
ghi|jklm|12345
SELECT * FROM xxx WHERE timestamp > "20000";
<no output>
So, you should check your CREATE TABLE statement for the datatype you
use for "timestamp" and the INSERT statement for the datatype you use
for the value inserted into the "timestamp" field.
Anyway, thanx for response. Hope to see more from you.
Again: please write EXACTLY what you did and NOT what you think you
might want to tell us.
Josef
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)