Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Database Maintenance

Author  Topic 

webfort
Starting Member

9 Posts

Posted - 2006-06-30 : 05:14:31
Hi

I was wondering if someone could help me, I'm trying to clean up some records on my database, I have managed to clean up a table of duplucate records, how ever this was in a relation to another table, is there anyway of clearing up the second table ie

If this number does not exist in this column then delete the record.

Would really appreciate it if any one could help, these are the two tables

[Customers] [orders]
Customerid Orderid
firstname Customerid

Thanks

Ashley

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-18 : 06:40:16
To find out which customers that not have an order
SELECT    Customers.*
FROM Customers
LEFT JOIN Orders ON Orders.CustomerID = Customers.CustomerID
WHERE Orders.OrderID IS NULL


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-18 : 11:42:41
or

SELECT *
FROM Customers C
Where not exists (Select * from Orders where CustomerID = C.CustomerID)



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -