Subject | use of 'LIKE %' |
---|---|
Author | Vahan Yoghoudjian |
Post date | 2005-04-21T07:16:53Z |
Hi group
I have a table containing stock item definitions where items have a
status (of type char(1)) to be differentiated. In the application the user
can decide what type of items to see according to values stored in a combo
box. Let's say the choices in the combo box are:
-All - %
-Products - P
-Services - S
-Bundles - B
-etc...
When the data in the combo is changed I use the following query to fetch the
item records
Select field1, field2,field3 from Items where Status LIKE :ItemStatus
The reason I use 'LIKE' and not '=' is to have a dynamic query for every
value selected from the combo and whenever the 'All' item is selected to use
the same query with the % key.
Is this a bad habit? Would it be better to change 'where status like
:ItemStatus' to 'where status = :ItemStatus' and omit this condition part
when all items have to be fetched or Firebird ignores conditions like 'LIKE
%' since all records have to be fetched anyway?
Thanks in advance
Vahan
[Non-text portions of this message have been removed]
I have a table containing stock item definitions where items have a
status (of type char(1)) to be differentiated. In the application the user
can decide what type of items to see according to values stored in a combo
box. Let's say the choices in the combo box are:
-All - %
-Products - P
-Services - S
-Bundles - B
-etc...
When the data in the combo is changed I use the following query to fetch the
item records
Select field1, field2,field3 from Items where Status LIKE :ItemStatus
The reason I use 'LIKE' and not '=' is to have a dynamic query for every
value selected from the combo and whenever the 'All' item is selected to use
the same query with the % key.
Is this a bad habit? Would it be better to change 'where status like
:ItemStatus' to 'where status = :ItemStatus' and omit this condition part
when all items have to be fetched or Firebird ignores conditions like 'LIKE
%' since all records have to be fetched anyway?
Thanks in advance
Vahan
[Non-text portions of this message have been removed]