Subject FROM Markus Ostenried
Author james_027
FROM Markus Ostenried

select *
from customer
where (type = :paramtype) or (Cast('*' as VarChar(3)) = :paramtype)

I find this sql statement a master piece. You did a wonderful job
Markus Ostenried. At first I really don't understand the sql after
after a careful observation, I then understand what is does.

But Iam not so sure what really happens internally.


You use varchar right? I tried to use char and I got the same result,
is their any difference from using VarChar from Char?

Before I used to use this trick. For example

select *
from customer
where '1'='1'

From what I learn is we can use this

select *
from customer
where (type = :paramtype) or ('*' = :paramtype)

If the type field has a column width of 1, right?

But what don't get is this ... cast('*' as varchar(3)) , before I
just knew that it is use in the select part of the sql statement.