Tuesday, March 1, 2011

Query To Find All Records under a specified component

Following is the query that can be useful to find out all records under a specified component.

 

SELECT DISTINCT (recname)
FROM psrecdefn
WHERE recname IN
(SELECT DISTINCT (recname)
FROM pspnlfield
WHERE pnlname IN
(SELECT DISTINCT (b.pnlname)
FROM pspnlgroup a, pspnlfield b
WHERE (   a.pnlname = b.pnlname OR a.pnlname =b.subpnlname)
AND a.pnlgrpname = 'Component Name'                 -- specify your component name)
AND recname <> ' ')
UNION
SELECT DISTINCT (recname)
FROM pspnlfield
WHERE pnlname IN
(SELECT DISTINCT (b.subpnlname)
FROM pspnlgroup a,pspnlfield b
WHERE (a.pnlname = b.pnlname OR a.pnlname = b.subpnlname )
AND a.pnlgrpname = 'Component Name')               -- specify your component name)
AND recname <> ' ')
AND rectype = '0'                                                 -- specify record type
order by recname asc

 

Note: 0 is a record type of Sql Table.

2 comments:

greenTech said...

Thanks this was useful.


Enje (http://gotecotech.com)

Unknown said...

Thanks Pawan. Its a great query.

Post a Comment