使用SQL查询的Where子句的问题 [英] problem in using where clause of sql query

查看:80
本文介绍了使用SQL查询的Where子句的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用select sql查询在网格中显示记录.

我必须显示产品编号,产品名称,产品价格,数量

我想在where子句中使用customerid,但customerid也在数据库表中.我不想在我的gridview控件中显示它.并用作customerid = label1.text的地方.

但是我想从数据库中获取它而不显示给网格.

解决方案

如果同一表中存在 customerid ,非常简单.
TableName 位置 TableName.customerid = 123


如果您需要加入
http://msdn.microsoft.com/en-us/library/aa213234%28v = sql.80%29.aspx [ ^ ]




你到底是什么意思?
我猜你需要像这样的东西:

从表名称中选择productid,productname,productprice,quntity,其中customerid = @ value

通过运行上面的查询,您将不会在结果中获得customerid.

注意:使用customerid = label1.text极其危险.我建议使用参数化查询.


i have to use the select sql query to show the records in grid.

i have to show the productid,productname, productprice, quntity

i want to use to customerid in where clause but customerid is also in the database table. i don''t want to show it in my gridview control.. and use as where customerid= label1.text.

but i want to fetch it from the database without showing it to grid.

how can i do it?

解决方案

Very Simple if customerid exists within the same table.

Select productid,productname, productprice, quntity from TableName
Where TableName.customerid=123 


If you need to join
http://msdn.microsoft.com/en-us/library/aa213234%28v=sql.80%29.aspx[^]


Hi,

What Exactly do you mean?
what I guess you need something like :

Select Productid,productname,productprice, quntity from tablename where customerid=@value

by running the above query, you wont get customerid in your results.

Notice: using customerid=label1.text is extremely dangerous. I recomend to use parameterized query.


这篇关于使用SQL查询的Where子句的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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