WHERE clause using IN

Results 1 to 2 of 2

Thread: WHERE clause using IN

  1. #1
    Join Date
    Dec 1969

    Default WHERE clause using IN

    There must be a better way of doing the WHERE clause below:<BR><BR>INSERT INTO #pnr_test<BR> (<BR> pnr_num<BR> , branch_code<BR> , status<BR> , datetimestamp_1<BR> , datetimestamp_2<BR> )<BR>SELECT PT.pnr_num<BR> , PT.branch_code<BR> , PT.status<BR> , PT.datetimestamp_1<BR> , PT.datetimestamp_2<BR>FROM pnr_test PT<BR>WHERE PT.pnr_num IN (SELECT pnr_num FROM pnr_test_source)<BR>AND PT.branch_code IN (SELECT branch_code FROM pnr_test_source)

  2. #2
    Join Date
    Dec 1969

    Default I don't understand why...

    ...you even HAVE a WHERE clause.<BR><BR>Oh...wait...I see. Two different tables.<BR><BR>So where did pnr_test come from??? Isn&#039;t it just a copy of all the records from pnr_test_source?<BR><BR>Oh, well, why couldn&#039;t you do<BR><BR>SELECT ...<BR>FROM pnr_test AS PT, pnr_test_source AS PS<BR>WHERE PT.pnr_num = PS.pnr_num<BR>AND PT.branch_code = PS.branch_code<BR><BR>???<BR><BR>JOIN the two tables?<BR><BR>

Posting Permissions

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