基于布尔值的SQL选择

编程入门 行业动态 更新时间:2024-10-28 17:28:13
本文介绍了基于布尔值的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选择

本文发布于:2023-10-26 20:45:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1531300.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:布尔值   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!