sqlite 为什么 select like 有效而 equals 不行? [英] sqlite why select like works and equals does not?

查看:19
本文介绍了sqlite 为什么 select like 有效而 equals 不行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 sqlite3 数据库有问题,我执行以下查询

I have a problem with sqlite3 database, I execute the following queries

sqlite> select * from property where link like"http://www.domain.com/huur/den-bosch/appartement-48118689-meester-spoermekerlaan-88/";

sqlite> select * from property where link like "http://www.domain.com/huur/den-bosch/appartement-48118689-meester-spoermekerlaan-88/";

我得到两行

17|2014-11-03|Meester Spoermekerlaan88|http://www.domain.com/huur/den-bosch/appartement-48118689-meester-spoermekerlaan-88/|5237JZ|Den Bosch|€789|3|1

17|2014-11-03|Meester Spoermekerlaan 88|http://www.domain.com/huur/den-bosch/appartement-48118689-meester-spoermekerlaan-88/|5237 JZ|Den Bosch|€ 789|3|1

32|2014-11-03|Meester Spoermekerlaan88|http://www.domain.com/huur/den-bosch/appartement-48118689-meester-spoermekerlaan-88/|5237JZ|Den Bosch|€789|3|1

32|2014-11-03|Meester Spoermekerlaan 88|http://www.domain.com/huur/den-bosch/appartement-48118689-meester-spoermekerlaan-88/|5237 JZ|Den Bosch|€ 789|3|1

然后我执行相同的查询,但使用相等运算符,就像这样

Then I execute the same query, but using the equality operator, like so

sqlite> select * from property wherelink="http://www.domain.com/huur/den-bosch/appartement-48118689-meester-spoermekerlaan-88/";

sqlite> select * from property where link="http://www.domain.com/huur/den-bosch/appartement-48118689-meester-spoermekerlaan-88/";

sqlite> (<---- 没有结果??)

sqlite> (<---- no results??)

我已经找到了与我类似的答案,但是问题不一样,我的字段是数据类型文本",正如您在此处看到的:https://stackoverflow.com/a/14823565/279147

I already found a similar answer to mine, however the issue is not the same, my fields are of datatype "text", as you can see here: https://stackoverflow.com/a/14823565/279147

sqlite> .schema 属性

sqlite> .schema property

CREATE TABLE 属性(id 整数 PRIMARY KEY AUTOINCREMENT UNIQUE、日期"文本、地址文本、链接文本、邮政编码文本、城市文本、价格文本、房间文本、页面整数);

CREATE TABLE property (id integer PRIMARY KEY AUTOINCREMENT UNIQUE,"date" text,address text,link text,postcode text,city text,price text,rooms text,page integer);

那么有人知道为什么会发生这种情况吗?这是我的版本信息

So does anybody have any idea why this would happen? here is my version information

root@s1:/# sqlite3 application.sqlite3

root@s1:/# sqlite3 application.sqlite3

SQLite 3.7.3 版

SQLite version 3.7.3

推荐答案

我遇到了同样的问题.这项工作对我有用.

I had the same problem. This work around worked for me.

SELECT * from foo WHERE CAST(name AS BLOB) = CAST('bla' AS BLOB);

SELECT * from foo WHERE CAST(name AS BLOB) = CAST('bla' AS BLOB);

这篇关于sqlite 为什么 select like 有效而 equals 不行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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