Solved

Select from 2 tables?  SQL 2005

Posted on 2009-05-17
4
179 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
create an aggregate function 9 36
Whats wrong in this query - Select * from tableA,tableA 11 32
Tsql query 6 22
Need help with a Stored Proc on Sql Server 2012 4 11
I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

832 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