Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to display rows that do not equal 1

Status
Not open for further replies.

johnhig

MIS
Jun 25, 2007
54
US
Good Morning,

I need some help with this query. I have 2 tables with part numbers in them. I am trying to return all the part numbers from table A that do not equal the part numbers from table B.

When I run this query it matches fine.

SELECT Powerscreen.Item_Number, Powerscreen.Item_Description, Powerscreen.discount30
FROM Powerscreen INNER JOIN
IM1_InventoryMasterfile ON Powerscreen.Item_Number = IM1_InventoryMasterfile.ItemNumber

When I run this query I get an endless result set.

SELECT Powerscreen.Item_Number, Powerscreen.Item_Description, Powerscreen.discount30
FROM Powerscreen INNER JOIN
IM1_InventoryMasterfile ON Powerscreen.Item_Number <> IM1_InventoryMasterfile.ItemNumber

What am I doing wrong?
Thanks John
 
Code:
SELECT Powerscreen.Item_Number, 
       Powerscreen.Item_Description, 
       Powerscreen.discount30
FROM   Powerscreen 
       [!]LEFT[/!] JOIN IM1_InventoryMasterfile 
         ON Powerscreen.Item_Number = IM1_InventoryMasterfile.ItemNumber
[!]Where  IM1_InventoryMasterfile.ItemNumber Is NULL[/!]

A left join will return all records from the left table and matching records from the right table. If there is no matching record, the fields will be null (which is why I included that in the where clause).

If any of this doesn't make sense, or you want further clarification, let me know.




-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top