in reply to Getting info from 2 tables

Ehhhhhh???? What's the question? Some of us monks are old sonny and you have to talk R E A L  C L E A R about what you want us to do for you.
()-()
 \"/
  `                                                     

Replies are listed 'Best First'.
Re: Re: Getting info from 2 tables
by cjacksonjr (Novice) on Jul 30, 2002 at 18:53 UTC
    There are two tables (notifAlarmlog and rhic_au_fy_01)in a Sybase Db. The fields are , seperated. The names above the data are the column titles. The program here counts (total number of alarms, those <2 secs., those =>2 and <10 secs., and those >10 secs). Now I have to use the info from the second table (rhic_au_fy_01) to filter out the alarms in notifLogTable that occur w/in 10 secs. of a Quench Event (ev-yquench or ev-bquench).
      Is this what you are trying to do:

      Hi, I've got two database tables and I'm trying to remove records from the first table that match a value in the second table.

      If that's the case, it sounds like what you need is a SQL join. For instance:
      (untested SQL code)

      SELECT foo_id FROM foo, bar WHERE paco < (waco + 10) AND paco > (waco - 10)
      Here's the steps to take:
      1. using DBI, run a SELECT SQL statement returning a result set based upon a JOIN of the two tables.
      2. Going through each value in the record set, run a DELETE of the records that you want to remove.
      I bet that there are some SQL gods out there who could do it through a single SQL statement, but for me SQL delete statements that complex give me the jitters.
      ()-()
       \"/
        `