Solved

Select from 2 tables?  SQL 2005

Posted on 2009-05-17
4
190 Views
Last Modified: 2012-05-07
I need to perform this query.

Select firstname, email from dbo.providers where (Active = '1')  AND   (BIO from dbo.BIOS = '' where dbo.providers ID = dbo.bios ID)  

The column ID in dbo.providers is an identity column and also is identical in dbo.BIOS.  

I basically want to select the firstname and email from the providers table where their bio is blank in the bios table, and where Active = '1' in the providers table.

I hope this made sense.  


SQL 2005
0
Comment
Question by:arthurh88
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Expert Comment

by:Aanvik
ID: 24407048
Try this.
Select firstname, email from dbo.providers A
       LEFT JOIN dbo.BIOS B on A. providers ID  
       where A.Active = '1'  AND B.BIOS = '' 

Open in new window

0
 
LVL 60

Expert Comment

by:chapmandew
ID: 24407075
aanvik, doing a left join won't help you at all in the query since you're setting criteria on the BIOS table in your where clause.

Select firstname, email from dbo.providers A
       INNER JOIN dbo.BIOS B on A. providers ID  
       where A.Active = '1'  AND ISNULL(B.BIOS, '') = ''
0
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
ID: 24407083
sorry, that was all messed up.

Select firstname, email from dbo.providers A
       INNER JOIN dbo.BIOS B on A.ID= B.ID
       where A.Active = '1'  AND ISNULL(B.BIOS, '') = ''
0
 

Author Closing Comment

by:arthurh88
ID: 31582403
thank you that worked!
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

624 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