使用mysql中的选定变量查询数据库 [英] query database with selected variables in mysql
本文介绍了使用mysql中的选定变量查询数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试像变量一样执行ac#mysql
i am trying to do a c# mysql
select * from table where variable =(selected tableColumn from dropdownlist)
(文本框中的文本没有人知道查询在我的sql中应该是什么样子.
like variable(text from text box does anyone know what the query should look like in my sql
推荐答案
MySqlCommand cmd = new MySqlCommand("Select * from table where variable = '@selectedValue'");
cmd.Parameters.AddWithValue("@selectedValue", value);
...
事实证明您不能在mysql中使用列名作为参数,所以我为从下拉列表中选择的每一列写了不同的select语句
turns out you cannot use column names as a parameter in mysql so I wrote I different select statement for each column chose from the dropdown list
select * from table where variable in (selected tableColumn from dropdownlist)
>
这篇关于使用mysql中的选定变量查询数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文