MySQL Forums
Forum List  »  German

Re: Alle FLOAT Spalten einer Datenbank ändern
Posted by: Thomas Wiedmann
Date: May 27, 2011 12:23PM

Hast Du schon mal ROUND() probiert?

CREATE TABLE test_dec (
 id INT NOT NULL,
 wert_float FLOAT NOT NULL,
 wert_dec DEC(10,2) NOT NULL,
 PRIMARY KEY (id)
);

INSERT INTO test_dec VALUES
(1, 10, 10), 
(2, 20.11, 20.11);

SELECT *
  FROM  test_dec
 WHERE ROUND(wert_float, 2) = 10;
+----+------------+----------+
| id | wert_float | wert_dec |
+----+------------+----------+
|  1 |         10 |    10.00 |
+----+------------+----------+
1 row in set (0.00 sec)

mysql> 

SELECT *
  FROM  test_dec
 WHERE ROUND(wert_float, 2) = 20.11;
+----+------------+----------+
| id | wert_float | wert_dec |
+----+------------+----------+
|  2 |      20.11 |    20.11 |
+----+------------+----------+
1 row in set (0.02 sec)

mysql>


Ansonsten verstehe ich nicht wirklich, warum Du die identische Zahlendarstellung brauchst, letztlich ist die Ausgabe nur eine Art formatierung der Werte und dabei werden bei DEC(10,2) eben zwei Nachkommastellen angehängt.

Grüße
Thomas

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Alle FLOAT Spalten einer Datenbank ändern
1100
May 27, 2011 12:23PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.