Mailing List Archive



Back to the month index Back to the list index

Gary Bickford (garyb@fxt.com)
Tue, 3 Sep 1996 19:58:00 -0700 (PDT)


Date: Tue, 3 Sep 1996 19:58:00 -0700 (PDT)
Message-Id: <v01540b05ae523b230044@[204.245.248.249]>
From: garyb@fxt.com (Gary Bickford)
Subject: [mSQL] Select - not the union, but the...

Sorry for crossposting - this seems relevant to both lists.

I have an msql db, and am using php. The keys for two tables are the isbn
"numbers" (actually strings, since there's an occasional "X") I need to
find all the items in either of two tables that are _not_ in the other
table. In other words, all the isbn's that are only in one of the tables
but not the other.

Silly me - the first thing I tried was like this:

        select books.isbn,refer.isbn where books.isbn <> refer.isbn

I forgot that this is true for all records that don't match. Fifteen
minutes and 12,000 records later, msqld finished. I actually ^C'd out of
msql after a minute or so, but msqld kept on chugging till it was done.

Using PHP, I could build an array from the smaller table and then search
the larger for each element. I thought somebody might have a better idea.

You'll probably tell me that msql1.0.16 can do this:

select books.isbn,refer.isbn where books.isbn NOT IN refer.isbn

and I'll have to upgrade. Well, that's OK, if I have to.

Thanks!
gb

        | end
      --+-- Gary Bickford <garyb@fxt.com>
        | FXT Corp. / Informat Communications
        | 541-923-3060
        | fax 541-923-5537

--------------------------------------------------------------------------
To remove yourself from the Mini SQL mailing list send a message containing
"unsubscribe" to "unsubscribe" to msql-list-request@bunyip.com. Send a message containing
"info msql-list" to majordomo@bunyip.com for info on monthly archives of
the list. For more help, mail owner-msql-list@bunyip.com NOT the msql-list!