MySQL-da buzilgan raqamlarni saqlash

Misol uchun, masalan, 10,54 belgini float yoki ikkilamchi sifatida saqlashni istagan ma'lumotlar bazasiga egaman.

Harorat deb ataladigan ustunli stol bor, ammo masala so'rovi bilanoq men kiritgan so'zlar yaxshi ketgan bo'lsa ham, u yuqorida keltirilgan misolda har doim aniq raqamni qaytaradi.

Ular jadval va bayonotlar. Iltimos yordam bera olasizmi?

Jadval:

CREATE TABLE `data_facts` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `network_asset_code` varchar(255) NOT NULL DEFAULT '',
  `temperature` double(255,0) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1;

Mumkin bo'lgan so'rov:

INSERT INTO data_facts (network_asset_code, temperature) VALUES ('abc', 10.5)

Bir so'rov:

mysql> select * from data_facts where data_facts.id=1;
+----+--------------------+-------------+
| id | network_asset_code | temperature |
+----+--------------------+-------------+
|  1 | abc                |          10 |
+----+--------------------+-------------+
1 row in set (0.00 sec)
1

9 javoblar

formatdagi haroratni o'zgartiring, agar 2 ta kasrli belgini xohlasangiz, er-xotin (255,2) dan foydalaning

CREATE TABLE `data_facts` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `network_asset_code` varchar(255) NOT NULL DEFAULT '',
  `temperature` double(255,2) DEFAULT NULL,
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1;
1
qo'shib qo'ydi

formatdagi haroratni o'zgartiring, agar 2 ta kasrli belgini xohlasangiz, er-xotin (255,2) dan foydalaning

CREATE TABLE `data_facts` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `network_asset_code` varchar(255) NOT NULL DEFAULT '',
  `temperature` double(255,2) DEFAULT NULL,
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1;
1
qo'shib qo'ydi

formatdagi haroratni o'zgartiring, agar 2 ta kasrli belgini xohlasangiz, er-xotin (255,2) dan foydalaning

CREATE TABLE `data_facts` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `network_asset_code` varchar(255) NOT NULL DEFAULT '',
  `temperature` double(255,2) DEFAULT NULL,
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1;
1
qo'shib qo'ydi

Would recommend using DECIMAL instead of DOUBLE refer here. How many digits you can accommodate in DECIMAL refer here

0
qo'shib qo'ydi

Would recommend using DECIMAL instead of DOUBLE refer here. How many digits you can accommodate in DECIMAL refer here

0
qo'shib qo'ydi

Would recommend using DECIMAL instead of DOUBLE refer here. How many digits you can accommodate in DECIMAL refer here

0
qo'shib qo'ydi

Harorat turi ma'lumotini ikki baravarga o'zgartirish (255,2)

0
qo'shib qo'ydi

Harorat turi ma'lumotini ikki baravarga o'zgartirish (255,2)

0
qo'shib qo'ydi

Harorat turi ma'lumotini ikki baravarga o'zgartirish (255,2)

0
qo'shib qo'ydi