Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2008
    Posts
    2

    Question Unanswered: Need help with simple Query, multi column index...

    Hello,

    I am pulling my hair out over what should be a simple query, but for some reason I can't get it to work.

    I have two tables both with multi-column indexes and I need to delete rows in table 2 based on info in table 1.

    Example: Table1 (*'s denote unique key)

    *T1_bill,
    *T1_year,
    *T1_cat,
    *T1_line,
    T1_chg

    Example Table 2

    *T2_bill,
    *T2_year,
    *T2_cat,
    *T2_line

    I need to delete the records in table 2 based on the T1_chg value.

    Please help. I must be missing something as I feel I've done this before...

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Please post the SQL that you've got so far. That will help us formulate a correct answer for you a lot faster than the pseudo-data that you've posted.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Aug 2008
    Posts
    2
    Thanks for the reply. Nevermind though.

    Two minutes after posting it hit me.

    delete from table2 where exists(select * from table1 where T1_cat = T2_cat (etc, etc..)... AND T1_chg = 'YADA YADA')


    Thanks for the quick response.

  4. #4
    Join Date
    Jun 2005
    Posts
    319
    just a little nit and not sure if affects performance but I always do:

    (SELECT 1 FROM...)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •