如何通过地址获取记录

时间:2014-09-10 03:09:25

标签: sqlite

如何按地址选择客户记录。

var allUsers = db.Query<Customer>("Select * From Customer Where lower(CompanyName) =?" + " AND lower(Address) like ?",  Class1.Company.ToLower() , txtAddr.Text.ToLower() + "%");

Example:
Address : 123, Berry Road, ontario

如果我使用上面的select语句并在文本框Addr中输入berry,则搜索将返回0。

使用lower()是否正确?

1 个答案:

答案 0 :(得分:0)

试试这个:

var allUsers = db.Query<Customer>("Select * From Customer Where lower(CompanyName) =?" + " AND lower(Address) like ?",  Class1.Company.ToLower() , "%" +txtAddr.Text.ToLower() + "%");

您将获得lower(Address) like '%berry%'而不是lower(Address) like 'berry%'

这是 SqlFiddle Demo