Subject Re: SELECT ... WHERE ... LIKE ... question (Firebird 1.02)
Author wackoj123 <wackoj123@yahoo.com>
Hi Luc,

> So asking for a LIKE '__AB' will never get you any result
> back since ALL fields in the char column have a fix
> length of five and your asking for 4 chars.
>
> You may change your column to VARCHAR, make sure you trim
> the values and it will work.

Then this is a "feature" of LIKE... Because

SELECT Code FROM <Table> WHERE Code = "01AB"

does return this code; in this case SELECT does not have a problem
with the 4 or 5 characters (I have tested this to make sure this is
correct :-)).

> If you stay with CHAR(5) you can use:
>
> LIKE '__AB%'

That would not be an option in this case, because this will also
return codes like __ABC - and I do not want those... :-)

> In this case you will get 01AB, but not 01DAB
>
> so, maybe:
>
> LIKE '__AB%' or LIKE '___AB' will do it, too.

What I have done now is check the length of the part after __ and if
it is two I add a space and use that result for the query. Not pretty
but it works.

> See above.
> It has nothing to do with LIKE, it's the CHAR definition.

But then again, as mentioned above the LIKE is the only not returning
results, while a plain query without wildcards works perfectly.

Best regards,

Jack