由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - parameterized queries with no inputs
相关主题
请教2个sql query 问题A SQL query never stop running is bothering me: help needed (转载)
SQL debug step into a store procedure from another one (转载)关于学习数据库我也说几句
一个SQL query的问题more HELP: how to make this sql more efficient?
[转载] question about SQL in Accessquery running long time
[转载] Can anyone interpret this simple SQL?一个求和的有日期限制的sql query 问题.
怎么样提高SQL SERVER的编程水平?sql query question
开班了Data Mining and OLAP
求被“开班”培养!How to write the query
相关话题的讨论汇总
话题: inputs话题: query话题: like话题: my
进入Database版参与讨论
1 (共1页)
p*********a
发帖数: 61
1
My application has a form to collect users' inputs, which are passed to a
parameterized SQL query over a table. When a user skips some boxes in the
form, the query should have no predicates on the corresponding attributes.
An extreme case is if the user inputs nothing, the query should return the
entire table.
My question is if the parameterized query is prefixed, what values are
supposed to be used for the parameters whose boxes are empty?
I understand that there are some solutions to work around. For example, for
string fileds, I can use LIKE '@para' to process. @para is % when the box is
empty; otherwise, @para is what the user inputs. However, my concern is
that the processing of LIKE operation is slow, as the evaluation of LIKE '%'
would scan the table to match.
Are there any other solutions? or my concern is unnecessary? or should skip
the parameterized query?
many thanks,
B*****g
发帖数: 34098
2
1. 每次根据输入用不同的SQL
2. (@para IS NULL OR col = @para)

for
is
%'
skip

【在 p*********a 的大作中提到】
: My application has a form to collect users' inputs, which are passed to a
: parameterized SQL query over a table. When a user skips some boxes in the
: form, the query should have no predicates on the corresponding attributes.
: An extreme case is if the user inputs nothing, the query should return the
: entire table.
: My question is if the parameterized query is prefixed, what values are
: supposed to be used for the parameters whose boxes are empty?
: I understand that there are some solutions to work around. For example, for
: string fileds, I can use LIKE '@para' to process. @para is % when the box is
: empty; otherwise, @para is what the user inputs. However, my concern is

a9
发帖数: 21638
3
.net?
DBValue.Null

for
is
%'
skip

【在 p*********a 的大作中提到】
: My application has a form to collect users' inputs, which are passed to a
: parameterized SQL query over a table. When a user skips some boxes in the
: form, the query should have no predicates on the corresponding attributes.
: An extreme case is if the user inputs nothing, the query should return the
: entire table.
: My question is if the parameterized query is prefixed, what values are
: supposed to be used for the parameters whose boxes are empty?
: I understand that there are some solutions to work around. For example, for
: string fileds, I can use LIKE '@para' to process. @para is % when the box is
: empty; otherwise, @para is what the user inputs. However, my concern is

i****a
发帖数: 36252
4
you can also use CASE in the WHERE clause

for
is

【在 p*********a 的大作中提到】
: My application has a form to collect users' inputs, which are passed to a
: parameterized SQL query over a table. When a user skips some boxes in the
: form, the query should have no predicates on the corresponding attributes.
: An extreme case is if the user inputs nothing, the query should return the
: entire table.
: My question is if the parameterized query is prefixed, what values are
: supposed to be used for the parameters whose boxes are empty?
: I understand that there are some solutions to work around. For example, for
: string fileds, I can use LIKE '@para' to process. @para is % when the box is
: empty; otherwise, @para is what the user inputs. However, my concern is

g***l
发帖数: 18555
5
STORED PROCEDURE不就是专门HANDLE这个的吗?
L*******r
发帖数: 8961
6
这个很同意。

【在 g***l 的大作中提到】
: STORED PROCEDURE不就是专门HANDLE这个的吗?
1 (共1页)
进入Database版参与讨论
相关主题
How to write the query[转载] Can anyone interpret this simple SQL?
oracle和XML怎么样提高SQL SERVER的编程水平?
帮帮忙开班了
How to query a tree求被“开班”培养!
请教2个sql query 问题A SQL query never stop running is bothering me: help needed (转载)
SQL debug step into a store procedure from another one (转载)关于学习数据库我也说几句
一个SQL query的问题more HELP: how to make this sql more efficient?
[转载] question about SQL in Accessquery running long time
相关话题的讨论汇总
话题: inputs话题: query话题: like话题: my