Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7530405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:54:10+00:00 2026-05-30T04:54:10+00:00

I was trying to write a query with inner join only if RepID of

  • 0

I was trying to write a query with inner join only if RepID of Table1 exists in Table2, if not do not join table2. With the query that i used below, i do not get from both the tables if repID doesnot exist in Table2. How is it possible? I am using sql server 2005. Thank you in advance!

Select * from Table1
inner join Table2 on Table1.RepID = Table2.RepID
where Table1.Date = @Date
order by Table1.Date desc
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:54:11+00:00Added an answer on May 30, 2026 at 4:54 am

    An inner join will only return a row if matches are found in both sides of the join. If you’re looking for something that will return all rows from Table1 but only records from Table2 when a match is found, you want a left outer join:

    select * from Table1 as t1
    left outer join Table2 as t2
        on t1.RepID = t2.RepID
    where t1.Date = @Date
    order by t1.Date desc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write an INNER JOIN query. I wanted to get rows/information that
Original Query I'm trying to rewrite: SELECT Table1.* FROM Table1 INNER JOIN Table2 ON
I'm trying to write the following LINQ-Entities query: Get a list of Questions, that
I'm trying to write a query that will pull back the two most recent
I'm trying to write a query that extracts and transforms data from a table
I'm trying to write a query that updates rows in a table if a
I am trying to write a query that connects 3 tables. The first table
I'm trying to write the following query in LINQ, but can't seem to get
I am trying to write a SQL query that pulls from 3 tables and
I'm trying to write a HQL/Criteria/Native SQL query that will return all Employees that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.