Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old October 12th, 2008, 12:25 AM
Lawrence Krubner
Guest
 
Posts: n/a
Default how does one get a set of items that are in one table but not inanother?


I hope this isn't already in some FAQ. (I did go to the MySql website
and search for "FAQ", but all I got was this:
http://search.mysql.com/search?q=faq.html&lr=lang_en)

Assume I have two database tables:

ftp_uploads
import_queue

One keeps track of all FTP uploads to a server (a cron script harvests
data out of the ftp logs and stores it in a database).

The other keeps track of meta data that needs to be stored in the
database, related to those FTP uploads.

So stuff gets uploaded to the database, then it needs to be imported to
our farm of NAS-connected boxes. All the servers run RedHat Linux. We
are using the PID (which the server assigns to each FTP upload) to link
the files in ftp_uploads with the data in import_queue. Every PID that
gets input into ftp_uploads should also appear in import_queue. However,
because of a programming error, we ended up with a few hundred entries
in ftp_uploads that were not also in import_queue. I'd like to delete
some of the entries.

My question: How do I find the rows in ftp_uploads that do not have a
matching PID in import_queue? The simplest thing seems like:

SELECT ftp_uploads.id
FROM ftp_uploads, import_queue
WHERE ftp_uploads.pid != import_queue.pid

But of course, that simply gives me the Cartesian product of all the
rows that match.




-- lawrence

  #2  
Old October 12th, 2008, 12:15 PM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
Default Re: how does one get a set of items that are in one table but notin another?

Lawrence Krubner wrote:
Quote:
I hope this isn't already in some FAQ. (I did go to the MySql website
and search for "FAQ", but all I got was this:
http://search.mysql.com/search?q=faq.html&lr=lang_en)
[...]
My question: How do I find the rows in ftp_uploads that do not have a
matching PID in import_queue? The simplest thing seems like:
>
SELECT ftp_uploads.id
FROM ftp_uploads, import_queue
WHERE ftp_uploads.pid != import_queue.pid
>
But of course, that simply gives me the Cartesian product of all the
rows that match.
I presume that *is* a FAQ since the MySQL documentation has it as an
example. Read on JOIN and ask further questions about it where MySQL
is on-topic:

comp.databases.mysql

See <http://jibbering.com/faq/#FAQ2_3>.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles