如何使用用户定义的列设置sql搜索命令? [英] how to setup sql search command with user defined column(s)?

查看:67
本文介绍了如何使用用户定义的列设置sql搜索命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个关于如何编写sqlcommand的复杂问题。我的数据库有例如5列,我想让用户选择要搜索的列,并根据用户搜索的列给出结果。

I have a complex question regarding how to write sqlcommand. my database has e.g. 5 columns, and I would like to let the user select which column to search and give the result based on the user searched column.

如果只有一列,这将很容易使用"SELECT * FROM mydata.mytable WHERE name ='" textBox1-> text"'"。

If there is only one column this would be quite easy using "SELECT * FROM mydata.mytable WHERE name='"textBox1->text"'".

但是,如果我有5列要定义,以防用户也不能在5中的一个或多个中输入任何值,情况变得更复杂......如果列出所有可能性,那么它将是2的5的幂,其中32个具有32
sqlcommands的可能性。 。

But if I have for example 5 columns to define and in case the user can also NOT enter any value in one or more in the 5, the situation becomes more complex... If one would list all possibilities it would be 2 to the power of 5 which 32 situations with 32 possibility of sqlcommands..

那么,有没有一种简单的方法呢?

So, is there an easy way to do it??

推荐答案

感谢您在此处发帖。

>>我有一个关于如何编写sqlcommand的复杂问题。我的数据库有例如5列,我想让用户选择要搜索的列,并根据用户搜索列给出结果。

此论坛是关于c ++代码问题的。如果您对如何编写sql命令只有疑问,请在technet上的sql论坛上发帖。例如:

This forum is about c++ code issues. If you only have question about how to write sql command, please post on sql forum in technet. For example:

https: //social.technet.microsoft.com/forums/en-us/home?forum=sqlsearch&filter=alltypes&sort=lastpostdesc

您的理解与合作将是感谢。

Your understanding and cooperation will be grateful.

最好的问候,

Baron Bi


这篇关于如何使用用户定义的列设置sql搜索命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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