Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL 2005 Left join

Posted on 2008-06-24
2
Medium Priority
?
589 Views
Last Modified: 2010-05-18
I have a query that is similar to the one below.  I am trying to get all the records from tableA but the where clause is removing the records. I want the records that do not exists in the table b to be null.
select max(cola)
from tableA
left join tableB on tableB.colB = tableA.colB
where tableA.colA<table.colB
group by tableA.colA

Open in new window

0
Comment
Question by:yanci1179
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 21855455
change:
select max(cola)
from tableA
left join tableB on tableB.colB = tableA.colB AND tableA.colA<table.colB
group by tableA.colA

Open in new window

0
 
LVL 43

Expert Comment

by:TimCottee
ID: 21855464
Hello yanci1179,

1:   select max(cola)
2:   from tableA
3:   left join tableB on tableB.colB = tableA.colB
4:   where tableA.colA<tableB.colB Or tableB.colB Is Null
5:   group by tableA.colA

Regards,

TimCottee
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question