AW: OT: Need some SQL advice

Tiemo Hollmann TB toolbook at kestner.de
Mon Nov 29 06:47:34 CST 2010


To be sure:
So I am right that it makes a better performance to have in the SQL
statement only thoses field comparisons which are actually needed, as all
fields with ="%"
Tiemo


> > 1. How do I design one generic SQL SELECT statement, which fits for
> all
> > queries, where I only have to feed the variables with the options.
> > Example: if the user uses only the selection in field 1 (and leaves
> all other
> > selection on wildcard) it is much faster to query only field 1:
> > WHERE f1=s1
> > instead of:
> > WHERE f1=s1
> > AND f2=s2 (where I set s2="%")
> > AND f3=s3 (where I set s3="%")
> > ...
> > AND f7=s7 (where I set s7="%")
> > But with this approach I can't setup one generic SQL statement which
> fits for
> > all queries. I would have to create douzends of SQL statements with
> all
> > possible combinations of selecting fields and would have to select
> the actual
> > SQL depending on the selection in my program. this isn't probably the
> way of
> > choice!? So how to do?
> 
> 1)
> 
> Old way -- you just use string concats to buld STRING of query where
> needed
> numbers are in place.
> 



More information about the Valentina mailing list