[英]How to get count of a particular item in mysql table using c#
I am tried to get count of a particular item from mysql table using c#.but i got nothing 我试图使用c#从mysql表中获取特定项目的计数,但我一无所获
My code 我的密码
string Batch = textBox8.Text;
string batchnumber = ("SELECT COUNT [Batch_No] FROM Orders where Batch_No='" + Batch + "'");
orders is my table and batch_no is the column and i want to get the count of particular batch number in the table.How can i do this? 我的表是orders,列是batch_no,我想获取表中特定批号的计数。我该怎么办?
Change COUNT [Batch_No]
to COUNT(Batch_No)
. 将
COUNT [Batch_No]
更改为COUNT(Batch_No)
。 It will work. 它会工作。
Try this: 尝试这个:
string Batch = textBox8.Text;
string batchnumber = ("SELECT COUNT(Batch_No) FROM Orders WHERE Batch_No='" + Batch + "'");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.