I'll add another version of the query to the one
@Sid Ogden gave (which is absolutely correct) with one that uses the
EXISTS statement:
siteid = 'WODM' and
exists(select null from longdescription where ldkey=pm.pmuid and ldownertable='PM'
and ldownercol='DESCRIPTION' and ldtext is not null)
The reason I'd suggest using EXISTS vs IN is the performance impact between the two methods.
The general rule is I've been told over the years is:
- Use
EXISTS when sub-querying on a large data set.
- Use
IN when sub-querying on a small data set.
The problem for most people when running queries is typically "we don't know what we don't know" on the dataset. So by default I've taught my Maximo power users to use
EXISTS as the safest syntax choice when you don't know how much information you're searching against.