SQL: Non-Equal Join of Two Tables 
Author Message
 SQL: Non-Equal Join of Two Tables

I am trying to get the records from one table where there are no values
within another table.  The tables are:

Employee           Hours
Empid                Empid
Name                 Projectid
Title                   Hours
Phone               Month

I tried the following statement:

SELECT DISTINCTROW Employee.Empid, Employee.Name, Employee.Phone
FROM Employee INNER JOIN Hours ON Employee.Empid = Hours.Empid;

This returns the employees where they exist in the Hour table.  This is
what I expected.  I modified it as follows:

SELECT DISTINCTROW Employee.Empid, Employee.Name, Employee.Phone
FROM Employee INNER JOIN Hours ON Employee.Empid <>Hours.Empid;

This ended up returning all of the records from the Employee table.  I
would appreciate some help.  I looked at nesting a query within a query and
this did not work either.  Thanks for all replies!

Bruce Murphy



Tue, 31 Aug 1999 03:00:00 GMT  
 SQL: Non-Equal Join of Two Tables


Quote:
>I am trying to get the records from one table where there are no values
>within another table.  The tables are:

Search help for LEFT JOIN and RIGHT JOIN.

Joe

Never underestimate the power of a WAG.

http://www.citilink.com/~jgarrick/vbasic/



Tue, 31 Aug 1999 03:00:00 GMT  
 SQL: Non-Equal Join of Two Tables


Quote:
> I am trying to get the records from one table where there are no values
> within another table.  The tables are:

> Employee           Hours
> Empid                Empid
> Name                 Projectid
> Title                   Hours
> Phone               Month
>----------

Bruce:
Try this...
    SELECT employee.EmpID FROM Employee WHERE Employee.EmpID NOT IN (SELECT
Hours.EmpID FROM Hours)


Thu, 02 Sep 1999 03:00:00 GMT  
 SQL: Non-Equal Join of Two Tables


writes:

Quote:
> Path:

news.uswest.net!uunet!in1.uu.net!128.230.129.106!news.maxwell.syr.edu!visi.com!
not-for-mail

Quote:

> Newsgroups: comp.lang.basic.visual.database,comp.lang.basic.visual.misc
> Subject: Re: SQL: Non-Equal Join of Two Tables

> >I am trying to get the records from one table where there are no values
> >within another table.  The tables are:

> Search help for LEFT JOIN and RIGHT JOIN.

> Joe

Hello
 Since your relationship is as follows:

Employee <------>> Hours

This would require the RIGHT JOIN operation vice INNER JOIN

Ray sends



Thu, 02 Sep 1999 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. SQL: Non-Equal Join of Two Tables

2. Joining two tables from two databases

3. Here's a sticky wicket - joining two tables on two diffrent servers with ADO

4. Table join between two tables in different databases

5. SQL - Join one table in one destination to another table in another destination (DBF)

6. Joining two tables from different databases

7. Creating a join on tables in two different MSSQL 6.5 DB's

8. How to Left join more than two table ?

9. How to Join two tables thrice?

10. Join two tables

11. Joining two tables on different length fields

12. Join two tables from seperate databases

 

 
Powered by phpBB® Forum Software