Results 1 to 2 of 2

Thread: JOIN Filter

  1. #1
    Ziggy Guest

    JOIN Filter

    I have two tables A and B. I want to insert data into tables C and D based on join between A and B (A.column = B.column). What is the best way to accomplish this type of task?

    IE-------> If column = xyz then insert into table C
    IF column = abc then insert into table D
    ELSE do_not_insert

    Please help.
    Regards

    Ziggy

  2. #2
    sam Guest

    JOIN Filter (reply)

    The best way...
    It seems simplest way to do following two statements

    Insert table_C
    select * from table_A A,table_B B
    where A.col = B.col
    and
    col = "xyz"


    Insert table_D
    select * from table_A A,table_B B
    where A.col = B.col
    and
    col = "abc

    To make it more efficient,it's probubly better to wrap it into 2 stored procedures and pass column value as a parameter.
    For me passing @tablename too and using 1 procedure is
    less efficient because of "optimizer stuff" ,but possible as well.

    s.

    ------------
    Ziggy at 8/24/99 3:27:48 PM

    I have two tables A and B. I want to insert data into tables C and D based on join between A and B (A.column = B.column). What is the best way to accomplish this type of task?

    IE-------> If column = xyz then insert into table C
    IF column = abc then insert into table D
    ELSE do_not_insert

    Please help.
    Regards

    Ziggy

Posting Permissions

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