基于布尔值的SQL选择 [英] SQL select based on Boolean values

查看:223
本文介绍了基于布尔值的SQL选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多文章.我有很多可能的关键字.每篇文章都有至少一个与之关联的关键字,但可能有许多关键字.有一个数据库,其中包含所有文章的列表,并且如果适用该关键字,则将每个关键字的布尔变量设置为true.
用户拥有所有关键字的列表,然后选择感兴趣的关键字.
我正在尝试找到一种比蛮横的SQL SELECT方法更优雅的方法来提取相关文章列表.
任何建议将不胜感激!

I have a large number of articles. I have a large number of possible keywords. Each article has at least one keyword associated with it, but may have many keywords. There is a database containing a list of all articles and a boolean variable set to true for each keyword if that keyword applies.
A user has a list of all keywords and selects those which interest them.
I am trying to find a more elegant way to extract the list of relevant articles than a brute force SQL SELECT.
Any suggestions would be appreciated!

推荐答案

我想您不会能够从选择语句中逃脱...也许您可以尝试为此使用存储过程,或者尝试优化选择,但并非没有选择,我认为

I guess you will not be able to escape from a select statement...maybe you could try to use a stored procedure for that, or try to optimize the select, but not without a select I think


我认为您的数据库设计不理想.您应该为所有文章提供一个表,并为所有可能的关键字提供一个表.在第三张表中,保存所有关键字-文章关联(使用文章和关键字的主键).
I think your database design is not ideal.. You should have a table for all the articles and a table for all possible keywords. In a third table you save all keyword-article associations (using the primary key of the article and keyword).


这篇关于基于布尔值的SQL选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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