MySQL: ABS() führt zu Überlauf
This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.
-
Testszenario
Source Code
- CREATE TABLE tabelle1 (
- id int(11) NOT NULL auto_increment,
- wert1 int(11) NOT NULL,
- wert2 int(11) NOT NULL,
- PRIMARY KEY (id)
- ) ENGINE=MyISAM;
- INSERT INTO tabelle1 (id, wert1, wert2) VALUES
- (1, 1, 2),
- (2, 2, 1);
- CREATE TABLE tabelle2 (
- id int(11) NOT NULL auto_increment,
- wert1 int(11) unsigned NOT NULL,
- wert2 int(11) unsigned NOT NULL,
- PRIMARY KEY (id)
- ) ENGINE=MyISAM;
- INSERT INTO tabelle2 (id, wert1, wert2) VALUES
- (1, 1, 2),
- (2, 2, 1);
Display All
Query
Source Code
- SELECT ABS(a.wert1-b.wert2) FROM tabelle1 a JOIN tabelle2 b ON a.id = b.id;
- +----------------------+
- | val |
- +----------------------+
- | 18446744073709551615 |
- | 1 |
- +----------------------+
- 2 rows in set (0.00 sec)
Workaround
Source Code
- SELECT IF(a.wert1>b.wert2,a.wert1-b.wert2,b.wert2-a.wert1) FROM tabelle1 a JOIN tabelle2 b ON a.id = b.id;