• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

Querying The Result Set of SQL Statement All in One statement

may be its late in the day and my mind is cooked, but I trying to create a stored proc that does the following....

I want to use this sql
SELECT DISTINCT EMPLNM
FROM cash_EmplList
WHERE EMPLNM like @prefix + '%'

To query the result of this sql...
      SELECT DISTINCT cash_EmplList.EMPLNM, cash_EmplList.EMPLID
FROM            cash_EmplList INNER JOIN
                         cash_Role ON cash_EmplList.EMPLID = cash_Role.EMPLID
WHERE        (cash_EmplList.RPT_TO_NM = @name) AND (cash_Role.ROLE = @role)

Can some help me write write 1 sql statement that does this...So get the result of the 2nd query first then use the first query to query that result.
0
npl77
Asked:
npl77
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
  SELECT DISTINCT cash_EmplList.EMPLNM, cash_EmplList.EMPLID
FROM            cash_EmplList INNER JOIN
                         cash_Role ON cash_EmplList.EMPLID = cash_Role.EMPLID
WHERE        (cash_EmplList.RPT_TO_NM = @name) AND (cash_Role.ROLE = @role)  and  cash_EmplList.EMPLNM like @prefix + '%'
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now