0

I'm using a field class that will filter a lookup list of companies to only show those that provide a certain service.

The 4 tables used are: PURCHVIEW,PCSRVCS,SRVCFETCH and COMPANIES and the method I'm using is:

void    setRelationship(java.lang.String objectName, java.lang.String whereClause)

so I'm restricted to just one object to link to and I've chosen COMPANIES since I want the company information from that table to be displayed in the lookup.

PURCHVIEW has a 'contractnum' attribute which is also included in PCSRVCS

PCSRVCS has the 'contractnum' and 'servicesid'

And finally SRVCFETCH has 2 attributes: 'servicesid' and 'company'

I'm quite lost with how to create the connection after doing:

"contractnum = (select contractnum FROM PCSRVCS where contractnum = :contractnum"

To summarize: Given the contractnum in PURCHVIEW, I need to check it with the contractnum in PCSRVCES --> Check the servicesid in PCSRVCES with that in SRVCFETCH --> Match the companies that have that serviceid in SRVCFETCH with the information in the COMPANIES table.

4

2 回答 2

1

您可以使用已经开始的子查询方法将多个表连接在一起。

此查询可能没有正确的表和字段名称,但根据您问题中提供的信息,它应该非常接近。

contractnum in (
    select contractnum from
            srvcfetch sf
            inner join pcsrvces ps on ps.serviceid = sf.serviceid
            inner join purchview pv on pv.contractnum = ps.contractnum
        where
            pv.contractnum = :contractnum
)
于 2014-05-23T14:31:54.893 回答
0

您可以通过在 SQL 管理工作室中创建自定义视图来设置/过滤 4 个表中所需的数据集来完成此操作。此视图将仅具有基于您想要的过滤条件的 contractnum 字段。(即创建视图 CustomViewName 作为 select contractnum from table1 join table2 join table3 etc.)。然后在你的 whereclause contition 中你需要做的就是contractnum in(从CustomViewName中选择contractnum)。

于 2014-05-15T18:16:26.613 回答