Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004

    Question Unanswered: Left Join And subquery

    Iwant to make a left join between two tables connected with a specific field
    but I also want to have some criteria on the right table.
    I want to display all the rows from the first(left) table and only the rows from the secod (right) table that match the join and the criteria.
    However If I have criteria on the second table the join behaves like an inner join displaying only the rows that exist in both tables.
    In MS Access instead of the right table I use a query in which I enter the criteria and then I connect it with a left join in a new query in order to get the right results. How can I do itin MSSQLServer without using Views?
    Must I use a subquery with Exists and what is the right syntax in order to achieve this?

    Best Regards,
    manolis Perrakis

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    select foo, bar
      from footable
    left outer
      join bartable
        on = bartable.fooid
       and bartable.qux = 'bat'
     where > 937 | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts