使用相同值且不重复文本的具有多个“where"字段的选择语句 [英] Select statement with multiple 'where' fields using same value without duplicating text

查看:16
本文介绍了使用相同值且不重复文本的具有多个“where"字段的选择语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我首先要说的是,我不认为我想要的事情可以完成,但是我希望我错了,有人比我知道得更多.所以这是你的机会......证明你比我更聪明:)

I will start by saying that I don't think what I want can be done, but that said, I am hoping I am wrong and someone knows more than me. So here is your chance... Prove you are smarter than me :)

我想对 SQLite 表进行搜索,以查找相似"的任何记录,而不必长篇大论地写出查询.

I want to do a search against a SQLite table looking for any records that "are similar" without having to write out the query in long hand.

澄清这就是我知道我可以编写查询的方式:

To clarify this is how I know I can write the query:

select * from Articles where title like '%Bla%' or category like '%Bla%' or post like '%Bla%'

如果您只检查几列,这很有效并且没什么大不了的,但是如果您需要检查一堆列,那么您的查询会变得非常长而且看起来非常快,更不用说有机会了错别字.(即:'Bla%' 而不是 '%Bla%')

This works and is not a huge deal if you are only checking against a couple of columns, but if you need to check against a bunch then your query can get really long and nasty looking really fast, not to mention the chance for typos. (ie: 'Bla%' instead of '%Bla%')

我想知道是否有一种快捷方式可以做到这一点?

What I am wondering is if there is a short hand way to do this?

*接下来的代码不能按照我想要的方式工作,但只是显示了我正在寻找的东西

*This next code does not work the way I want, but just shows kind of what I am looking for

select * from Articles where title or category or post like '%Bla%'

有人知道是否有一种方法可以指定多个where"列应该使用相同的搜索值,而无需为每一列列出相同的搜索值?

Anyone know if there is a way to specify that multiple 'where' columns should use the same search value without listing that same search value for every column?

提前致谢!

推荐答案

我认为考虑到您正在使用 sqlite,您应该考虑使用全文搜索.它会让你尝试做的事情更有效率.

I think considering you are using sqlite you should consider using Full Text Search. It'll make what you're attempting to do more efficient.

http://www.sqlite.org/cvstrac/wiki?p=FtsUsage

这篇关于使用相同值且不重复文本的具有多个“where"字段的选择语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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