我正在撰写一个问询,以便用户能够了解他们在 as、C#和msql中提供的关键词:
string projectPart = null;
string categoryPart = null;
string descriptionPart = null;
if (this.Textbox_ProjectNr.Text.Trim().Length > 0)
projectPart = " AND Number= " + this.Textbox_ProjectNr.Text.Trim() + " ";
if (this.Textbox_Category.Text.Trim().Length > 0)
categoryPart = " AND Category LIKE %" + this.Textbox_Category.Text.Trim() + "% ";
if (this.Textbox_pDescription.Text.Trim().Length > 0)
descriptionPart = " AND ProductDescription LIKE %" + this.Textbox_pDescription.Text.Trim() + "% ";
string query = "SELECT * from Project = p.ID " + projectPart + descriptionPart + categoryPart;
我很想知道,这一询问是否足以进行传统查询。 由于我看到这一搜索存在一些瓶颈:
- if the user does not type anything, it returns all of the data => For this I only do the query when one of the fields are filled.
- if the user provides some keywords "P" for each field, the result will be millions of data.
我知道如何从根本上改进查询。 欢迎任何建议。
先进。