Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 28th, 2005, 10:44 AM
Registered User
 
Join Date: Aug 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Find records that don't exist

In MySQL 4.0, is it possible to find all records that don't exist in one query. I managed to do it in Access by referencing a query that I had previously created, but I was wondering if it was possible to do this in one step.

SELECT C.CustomerID, ([JobStatus]="0" And [JobTypeID]=2) AS KountNA, Count([KountNA]) AS KountComplete
FROM Workorders AS W INNER JOIN Customers AS C ON W.CustomerID = C.CustomerID
GROUP BY C.CustomerID, ([JobStatus]="0" And [JobTypeID]=2)
HAVING (((([JobStatus]="0" And [JobTypeID]=2))=-1));

Would show all Customers that have JobTypeID=2 and JobStatus="0".

I then used a RIGHT JOIN to filter out all the records from the Customers table not in this query, as below:

SELECT C.CustomerID, QC.KountComplete, C.NameNumb, C.BillingAddress, C.City, C.PostalCode
FROM qryCountCompleteServices AS QC RIGHT JOIN Customers AS C ON QC.CustomerID = C.CustomerID
WHERE (QC.KountNA) Is Null);

So, can I do that without using a sub-query in MySQL 4.0?

Thanks

Andrew











Similar Threads
Thread Thread Starter Forum Replies Last Post
Exist Finder classes to find elements into List? jeusdi .NET Framework 1.x 4 February 19th, 2007 01:31 PM
Returnig records on EXIST ninel SQL Server 2005 1 January 2nd, 2007 08:17 PM
Find records that don't exist harg7769 Access 1 April 20th, 2005 08:16 AM
sql command to find duplicate records? qwjunk Classic ASP Databases 1 January 31st, 2004 03:32 PM
how to find total no. of records reshmisworld Classic ASP Basics 1 July 24th, 2003 08:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.