-1

在我的 SQLite DB 中,我有一个表,其中包含每个名称的纬度和经度值

产品

id , name (1000 条记录) , latitude(float) , longitude (float)

我必须从课堂上更新我的数据库,但我对运行查询有点困惑。我要做的是:我必须将所有 Lat、Long 值限制为小数点后四位,因此我需要一个查询来更新所有 lat、long 值,以便每个名称的 lat 或 long 值不得大于四位小数.

例如:UPDATE products set products.latitude upto .4f , products.longitude upto .4f where (选择product.latitude,product.longitude from products where latitude value >.4f or longitude value >.4f)

我没有得到确切的查询来做这件事。对此有何建议?

4

1 回答 1

2
UPDATE products
SET latitude = round(latitude, 4),
    longitude = round(longitude, 4)

这只是更新所有记录,因为浮点舍入错误使得无法确定实际位数。(SQLite 没有定点数。)

于 2012-12-22T11:41:11.193 回答