× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Evan,

Although not eloquent this will return the correct rows

Table1
id
name
1
Abe
2
Bob
3
Dave
4
Jacob
5
Jerry
6
John
7
Rob
8
Scott
9
Tim

Table2
id
name
1
Bob
2
J*
3
Rob

SELECT a.id, a.name
FROM table1 a
WHERE a.name IN (
SELECT b.name
FROM table1 b
WHERE b.name LIKE ((SELECT SUBSTRING(c.name, 1, 1)
FROM table2 c
WHERE c.name LIKE '%*%') + '%')
UNION
SELECT d.name
FROM table2 d
WHERE d.name NOT LIKE ((SELECT SUBSTRING(c.name, 1, 1)
FROM table2 c
WHERE c.name LIKE '%*%') + '%'))

Results
id name
2 Bob
4 Jacob
5 Jerry
6 John
7 Rob

HTH,
Robert Rogerson

On Thu, May 19, 2011 at 3:37 AM, John McKay <jmckay@xxxxxxxxxxxxxxxx> wrote:

Sorry Evan - I addressed you as Hans.

I beg your pardon.


On 19/05/2011 08:16, John McKay wrote:
Hi Hans,

How about something like this ....

if A = B;
// match found
else;

zpos = %scan('*': A);
if zpos> 1;
zlen = zpos - 1;

if %substr(A: zlen) = %substr(B: zlen);
// match found
else;
// no match found
endif;

else;
// no match found
endif; // zpos> 1

endif; // A = B


The expanded list would not be a good idea - you will never be sure
you have expanded fully enough.

Regards,
John Mckay mba
ww.mckaysoftware.ie
www.rpglanguage.com

On 19/05/2011 04:17, Evan Harris wrote:
Hi Guys

I have a project where I want to process a list of entries obtained
from a detail table against a control table to determine whether
certain processing should take place. Some kind of processing will
take place on all entries - the control file will determine which
entries will be treated differently.

For example, if processing a list of users e.g. BOB, CHARLIE, DAVID,
JACK, JOHN, MICHAEL and RICHARD
and a control file like BOB, DAVE, J*...

How would I match the JACK and JOHN detail entries to the J* entry in
the control table to retrieve processing control data ?

I've thought of a couple of possibilities but they seem to be ugly.
One was to first build an expanded the list by using the generic
entries to query the control table and then matching detail entries
against the expanded list.

Any other ideas out there ?

--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.