Reputation
26,825
Next tag badge:
95/100 score
23/20 answers
Badges
5 47 90
Newest
 Guru
Impact
~1.2m people reached

2h
comment Minimum value on most recent date per account
They probably want OVER (... ORDER BY CHRQDATE DESC, CHSCORE) but good answer.
4h
comment Minimum value on most recent date per account
Which DBMS? (Oracle, DB2, MySQL, SQL-Server, Postgres, ...)
4h
revised Minimum value on most recent date per account
added 64 characters in body
7h
comment What's faster: two UPDATEs with WHERE (in / not in) or one UPDATE with CASE?
Also SET a.enabled = (b.id IS NOT NULL);
8h
comment Modulo operator with nonintegers - unexpected results
@WAF thnx. My point of "K included" was about mysql's implementation. I've never used any math that involved modulo arithmetic with reals but for such math, the definition will probably not include the K value. But floats are not reals, they are just an emulation. Reals are infinite in number and precision, floats are not.
8h
comment Why would I need a third table in a one-to-many relationship?
I never said anything about nulls.
8h
comment Modulo operator with nonintegers - unexpected results
@RolandoMySQLDBA I tried to make a comment in your answer but you deleted: Using col - (0.1 * FLOOR(col / 0.1)) = 0.0 might be ok but I think this would not work in all cases either.
9h
revised Modulo operator with nonintegers - unexpected results
added 1015 characters in body
9h
comment MySQL: is it more efficient to query for duplicate row or insert(update) on duplicate?
How many rows per second do you expect to be inserting? If the volume is small, it may not be worth optimizing this. Just make something that works.
9h
comment MySQL: is it more efficient to query for duplicate row or insert(update) on duplicate?
Not sure. It will just avoid producing some gaps in the auto_increment column (if you have one.) I think the efficiency depends on how many duplicate values you expect. I suggest you do some testing with all options. My preference would on the ON DUPLICATE KEY or the NOT EXISTS version.
9h
answered Modulo operator with nonintegers - unexpected results
9h
comment MySQL: is it more efficient to query for duplicate row or insert(update) on duplicate?
There is a 3rd option: INSERT ... SELECT ... WHERE NOT EXISTS (...);
9h
comment
It is great that we have so many good candidates! And a hard choice for the voters.
9h
comment Why would I need a third table in a one-to-many relationship?
Doesn't the 0-1::1-M need an intermediate table as well?
10h
comment Modulo operator with nonintegers - unexpected results
Yes, I meant when they are float/double.
10h
comment Why would I need a third table in a one-to-many relationship?
I think you are claiming that all 1:M relationships are of the (common) 1-1::0-M type. But in many text books, the 1:M is a general term for the 4 cases 1-1::0-M, 0-1::0-M, 1-1::1-M, 0-1::1-M. Some of these cases do need an intermediate table - and perhaps that is what the OP's teacher said.
10h
comment Modulo operator with nonintegers - unexpected results
No, it is treated as double in both cases. But the result of 5850.0 mod 0.1 is 0.1 and not 0.0, it's as simple as that. I am convinced it's a float/double issue. "Why is that type not consistent?" Read the linked above pages again ;)
10h
comment Modulo operator with nonintegers - unexpected results
My point is that if you want to do precise arithmetic, use a precise type, not float, not double. Otherwise, you'll get weird and unexpected results like this one.
10h
comment Modulo operator with nonintegers - unexpected results
I suggest you start using decimal(15,6) instead of double: What Every Programmer Should Know About Floating-Point Arithmetic
10h
comment Modulo operator with nonintegers - unexpected results
Please edit the question and add the SHOW CREATE TABLE tablename; output.