在 SQLite 中将文本转换为数字 [英] Convert Text to Numbers in SQLite

查看:73
本文介绍了在 SQLite 中将文本转换为数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有以下结构的表的 sqlite 数据库 LocationName Latitude Longitude 全部定义为 varchar.我如何构建一个 sql 语句来获取具有特定纬度范围的所有位置(给定纬度以十进制表示).有没有办法即时从 varchar 转换为十进制值?或者我必须单步执行返回语句并手动进行转换

I have a sqlite DB with a table with the following structure LocationName Latitude Longitude all defined as varchar. How i can construct a sql statement to get all the locations with a specific lat range given latitude in decimal. is there a way to do that convert from varchar to decimal value on the fly ? or i have to step through the return statements and do the conversion manually

推荐答案

参见 http://www.sqlite.org/lang_expr.html.

SELECT CAST('3.02' as decimal)
-- they aren't real decimals in sqlite, though. beware floats.

这篇关于在 SQLite 中将文本转换为数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆