× 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.



Is what you're trying to get to

SELECT PRMNBR, EVTDTE, EVTTME, USRID, EVTRMK FROM P1FILES.KSEVT E
WHERE (EVTRMK LIKE 'CIS CONTRIB. ACCT #%'
AND EXISTS(SELECT * FROM P1FILES.KSEVT
WHERE PRMNBR = E.PRMNBR AND EVTID<> E.EVTID
AND EVTRMK LIKE 'CIS CONTRIB. ACCT #%'))
union all

SELECT PRMNBR, EVTDTE, EVTTME, USRID, EVTRMK FROM P1FILES.KSEVT f
WHERE (EXISTS(SELECT * FROM P1FILES.KSEVT
WHERE PRMNBR = E.PRMNBR AND EVTID > f.EVTID
AND EVTRMK LIKE 'CIS CONTRIB. ACCT #%'

?

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Graap, Kenneth
Sent: Tuesday, June 07, 2011 5:22 PM
To: Midrange Systems Technical Discussion
Subject: RE: Problem using OR in SQL Statement

Sorry the 3rd statement listed in this e-mail should have read...

Using the statement containing only the second portion of the Where clause, right of the 'OR', returns 1738 rows...

SELECT PRMNBR, EVTDTE, EVTTME, USRID, EVTRMK FROM P1FILES.KSEVT E WHERE (EXISTS(SELECT * FROM P1FILES.KSEVT
WHERE PRMNBR = E.PRMNBR AND EVTID > E.EVTID
AND EVTRMK LIKE 'CIS CONTRIB. ACCT #%') AND EXISTS(SELECT * FROM P1FILES.KSEVT
WHERE PRMNBR = E.PRMNBR AND EVTID < E.EVTID
AND EVTRMK LIKE 'CIS CONTRIB. ACCT #%')

Kenneth
Kenneth E. Graap
http://www.linkedin.com/in/kennethgraap


SO ................ I've corrected my original e-mail as follows.

This SQL select statement containing an 'OR' within the Where clause will not run to completion, hangs until cancelled...

SELECT PRMNBR, EVTDTE, EVTTME, USRID, EVTRMK FROM P1FILES.KSEVT E
WHERE (EVTRMK LIKE 'CIS CONTRIB. ACCT #%'
AND EXISTS(SELECT * FROM P1FILES.KSEVT
WHERE PRMNBR = E.PRMNBR AND EVTID<> E.EVTID
AND EVTRMK LIKE 'CIS CONTRIB. ACCT #%')) OR
(EXISTS(SELECT * FROM P1FILES.KSEVT
WHERE PRMNBR = E.PRMNBR AND EVTID> E.EVTID
AND EVTRMK LIKE 'CIS CONTRIB. ACCT #%')
AND
EXISTS(SELECT * FROM P1FILES.KSEVT
WHERE PRMNBR = E.PRMNBR AND EVTID< E.EVTID
AND EVTRMK LIKE 'CIS CONTRIB. ACCT #%'))


However, breaking the statement above apart and running the two parts separately does work...

Using the statement containing only the first portion of the Where clause, left of the 'OR', returns 390 rows...

SELECT PRMNBR, EVTDTE, EVTTME, USRID, EVTRMK FROM P1FILES.KSEVT E
WHERE (EVTRMK LIKE 'CIS CONTRIB. ACCT #%'
AND EXISTS(SELECT * FROM P1FILES.KSEVT
WHERE PRMNBR = E.PRMNBR AND EVTID<> E.EVTID
AND EVTRMK LIKE 'CIS CONTRIB. ACCT #%'))

Using the statement containing only the second portion of the Where clause, right of the 'OR', returns 1738 rows...

SELECT PRMNBR, EVTDTE, EVTTME, USRID, EVTRMK FROM P1FILES.KSEVT E WHERE (EXISTS(SELECT * FROM P1FILES.KSEVT
WHERE PRMNBR = E.PRMNBR AND EVTID > E.EVTID
AND EVTRMK LIKE 'CIS CONTRIB. ACCT #%'>


Does anyone know why this won't work with the OR ???????

This is being run on a V5R4M5 system...


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-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.