【问题标题】:Sql update query for latitude and longitude in sqlite [closed]SQLite中纬度和经度的Sql更新查询[关闭]
【发布时间】:2012-12-22 09:33:56
【问题描述】:

在我的 SQLite 数据库中,我有一个表,每个名称都有纬度和经度值

产品

id , name (1000 records) , latitude(float) , longitude (float)

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

例如 : 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)

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

【问题讨论】:

  • 纬度超过 0.4f 意味着它会多次存储相同的值
  • 我的意思是它应该更新数据库并将值设置为小数点后四位,只有数据库中的所有值都应该是小数点后四位不超过..我应该怎么做?

标签: ios sql database xcode sqlite


【解决方案1】:
UPDATE products
SET latitude = round(latitude, 4),
    longitude = round(longitude, 4)

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-12
    • 1970-01-01
    • 2011-03-10
    • 1970-01-01
    • 1970-01-01
    • 2019-02-24
    相关资源
    最近更新 更多