From: Rob <[EMAIL PROTECTED]> > Hi, I'm working on a script that has to find if there is a customer > number in one table that's not in the other. My first thought was to > write all customer numbers out to a file then sort them and go through > the first file one line at a time while going completly through the > other file each time. But from what I've seen with Postgres so far I > would bet that I could do the same thing with a select statement. > Would this be possible? Would I need to use a join for something like > this?
I've never worked with Postgres, but maybe something like this would work: select customer_no from Table1 where not exists (select * from Table2 where Table1.customer_no = Table2.customer_no) or maybe select customer_no from Table1 where Table1.customer_no not in (select customer_no from Table2) If you for whatever reason did try to search through the numbers yourself I would recomend 1) ask the Postgres to sort the numbers, don't do it yourself select customer_no from Table1 order by customer_no 2) instead of saving the numbers from the second table to a flat file and searching the file completely each time keep them in a hash. And if the hash would be too big, use DB_File or some similar module to keep the hash on disk. In either case this will be much much quicker. Jenda =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ========== There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]