SQL Server Performance

names from id results

Discussion in 'Getting Started' started by cb, May 23, 2007.

  1. cb New Member

    i have a query that returns successful results getting the distinct id from a enquireies table as follows:
    select DISTINCT enq.enqid, enq.empid
    from enquiry enq
    inner join edetails b
    on enq.enqid = b.enqid

    this gets me the enqid associated with the rows but i want to display names from employee table using results on empid from above query.

    help me please.
  2. Adriaan New Member

    Add another join with the employee table. If empid on the enquiry table allows nulls, make it a left join (assuming you're mentioning the enquire table first) and just note that you might get nulls on the employee name column.
  3. cb New Member

    adrian thanks for the suggstion. im new to joins is it possible to write query by you.
  4. Adriaan New Member

    Your query already has a join, it should not not be that difficult to add another one.[<img src='/community/emoticons/emotion-5.gif' alt=';)' />]
  5. cb New Member

    thanks that is correcte direction. i got that
  6. Adriaan New Member

    Let us know what solution you find.[<img src='/community/emoticons/emotion-1.gif' alt=':)' />]
  7. Madhivanan Moderator

  8. satya Moderator

    I believe the originator is not a stated in SQL if you look at the initial query. [<img src='/community/emoticons/emotion-1.gif' alt=':)' />].<br /><br /><b>Satya SKJ</b><br />Microsoft SQL Server MVP<br />Writer, Contributing Editor & Moderator<br /<a target="_blank" href=http://www.SQL-Server-Performance.Com>http://www.SQL-Server-Performance.Com</a><br /><center><font color="teal"><font size="1">This posting is provided AS IS with no rights for the sake of <i>knowledge sharing. <hr noshade size="1">Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.</i></font id="size1"></font id="teal"></center>
  9. cb New Member

    thanks madhivan as satya referred i m not a learner in sql server.

Share This Page