Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
Let say I have a table with Brands:
Brand
YAMAHA
SELMER
....
I have an other table with product name which include the brand name
ProductName
Drums YAMAHA xxx
Saxophone Alto SELMER
SELMER Saxophone barython
I would like to create a link between these two table using a wild card search of the Brand into the ProductName.
Is there any function I can use in the script to achieve this.
Thanks
Philippe
Think that WILDMATCH-function should help you a bit:
// ======================== Load a list of Brandnames
Brand:
LOAD
*
INLINE [Brand
YAMAHA
SELMER];
// ========================== Load a list of Products
Products:
LOAD * INLINE [
ProductName
Drums YAMAHA xxx
Saxophone Alto SELMER
SELMER Saxophone barython];
// ======== Loop through Products checking for Brands
FOR i = 1 TO NoOfRows('Brand')
LET sBrand = PEEK('Brand', i-1, 'Brand');
Product_n_Brand:
LOAD
ProductName,
'$(sBrand)' AS Brand
RESIDENT
Products
WHERE
WILDMATCH(ProductName, '*$(sBrand)*');
NEXT i
DROP TABLE Products;
HTH
Peter
Think that WILDMATCH-function should help you a bit:
// ======================== Load a list of Brandnames
Brand:
LOAD
*
INLINE [Brand
YAMAHA
SELMER];
// ========================== Load a list of Products
Products:
LOAD * INLINE [
ProductName
Drums YAMAHA xxx
Saxophone Alto SELMER
SELMER Saxophone barython];
// ======== Loop through Products checking for Brands
FOR i = 1 TO NoOfRows('Brand')
LET sBrand = PEEK('Brand', i-1, 'Brand');
Product_n_Brand:
LOAD
ProductName,
'$(sBrand)' AS Brand
RESIDENT
Products
WHERE
WILDMATCH(ProductName, '*$(sBrand)*');
NEXT i
DROP TABLE Products;
HTH
Peter
Thanks a lot ....
That helps.
Philippe
What if i add a brandname : SELM.
Then i will have 2 matches. How can i only get one match? first found match
Great example btw
and what if i want to put the non matches in an 'other' Brandname?
Oops.. sorry, didn't mean to suggest that last post as an answer.
FYI - using the NOT keyword before the wildmatch works for me when wanting to exclude matches i.e.
NOT WILDMATCH(ProductName, '*$(sBrand)*');