jaddybalagtas
25th April 2007, 10:46
Hi,
I am having problems with my script the problem is I have to get the items where the description is like the ones that the user enters I have 2 sessions the first get the word that the user is looking for then I import that value to the next session and filters the items that is like that word but it is not working :
before.program:
import("dsca",dsca)
select tiitm001.* from tiitm001
where tiitm001.dsca like "dsca"
selectdo
endselect
main.table.io:
after.read:
select tiitm001.* from tiitm001
where tiitm001.dsca like "dsca"
selectdo
selectempty
skip.io("ttiitm001")
endselect
george7a
25th April 2007, 11:41
Hi,
When you use "" it means you mean that specific text. so in your SQL you are looking for a description that has "dsca" in it.
This is a part of the SQL documentation:
LIKE operator
The LIKE operator compares operand1 with operand2. Operand2 can contain wild cards. For example:
WHERE name LIKE "[Tt]riton.*"
In this example, "Triton2.1" and "triton" are legal values. In this case, operand2 is a regular expression. See the expr.compile() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_expressions_runtime_expr_compile) function for a list of the possible features that the expression can contain.
More info is on:
http://www.baanboard.com/programmers_manual_baanerp_help_functions_database_handling_where
You might also consider using the dynamic SQL:
http://www.baanboard.com/programmers_manual_baanerp_help_functions_database_handling_dynamic_sql
I hope it helps,
- George
spartacus
25th April 2007, 11:44
Hmm, I'm not that experienced with "like" but for me it looks like u forgott some wildcards.
I'm not sure, but IMHO the Window astriks "*" has to be replaced in a like statement by ".*" which should mean: "Any character (the dot) zero up to any number of that characters (the asterix).
mr_suleyman
25th April 2007, 15:33
Try in your like statement like "*dsca.*"
This should work for your case
g.Luck !
saenzh
29th May 2020, 23:44
Hi I was having a similar issue but I used double quotes instead of single quotes and it worked.
Your code:
where tiitm001.dsca like "dsca"
Try this:
where tiitm001.dsca like ".*dsca.*"
vahdani
1st June 2020, 01:06
Hi,
please try following:
select tiitm001.*
from tiitm001
where tiitm001.dsca like ".*" & trim$(dsca) & ".*"
or maybe (?)
string l.like.sting(20)
l.like.string = ".*" & trim$(dsca) & ".*"
select tiitm001.*
from tiitm001
where tiitm001.dsca like :l.like.string