yoonie_85

10-13-2004, 11:49 AM

hello

i'm in desperate need of some help, as it is urgent...i have taken a lot of different approaches to this problem, but nothing seems to be working.

here's what i'm trying to do...

I am trying to write a query in access in which I am comparing two tables.

tabel1 has 2 id numbers in the first 2 fields, and a phone number in the 3rd field

table 2 has 2 id numbers, and 3 emtpy fields for phone number, Yes column and No Column.

I have to take each pair of ID numbers fromthe 1st table and check to see if the same pair is in the second table. If so, I want to add the phone number to the 2nd table and inclue yes or no in the corresponding column.

any help would be greatly appreciated. Thank you.

so far i've got this:

UPDATE Original

SET WH = CASE

WHEN EXISTS (SELECT Original.PremCode FROM Original, Data

WHERE Original.PremCode = Data.PREM_CODE AND

Original.CustCode = Data.CUST_CODE)

THEN 'Y'

END,

WH_Rental = CASE

WHEN EXISTS (SELECT Original.PremCode FROM Original, Data

WHERE Original.PremCode = Data.PREM_CODE AND

Original.CustCode = Data.CUST_CODE)

THEN 'N'

END,

WH_Constant = CASE

WHEN EXISTS (SELECT Original.PremCode FROM Original, Data

WHERE Original.PremCode = Data.PREM_CODE AND

Original.CustCode = Data.CUST_CODE)

THEN 'N'

END

i'm in desperate need of some help, as it is urgent...i have taken a lot of different approaches to this problem, but nothing seems to be working.

here's what i'm trying to do...

I am trying to write a query in access in which I am comparing two tables.

tabel1 has 2 id numbers in the first 2 fields, and a phone number in the 3rd field

table 2 has 2 id numbers, and 3 emtpy fields for phone number, Yes column and No Column.

I have to take each pair of ID numbers fromthe 1st table and check to see if the same pair is in the second table. If so, I want to add the phone number to the 2nd table and inclue yes or no in the corresponding column.

any help would be greatly appreciated. Thank you.

so far i've got this:

UPDATE Original

SET WH = CASE

WHEN EXISTS (SELECT Original.PremCode FROM Original, Data

WHERE Original.PremCode = Data.PREM_CODE AND

Original.CustCode = Data.CUST_CODE)

THEN 'Y'

END,

WH_Rental = CASE

WHEN EXISTS (SELECT Original.PremCode FROM Original, Data

WHERE Original.PremCode = Data.PREM_CODE AND

Original.CustCode = Data.CUST_CODE)

THEN 'N'

END,

WH_Constant = CASE

WHEN EXISTS (SELECT Original.PremCode FROM Original, Data

WHERE Original.PremCode = Data.PREM_CODE AND

Original.CustCode = Data.CUST_CODE)

THEN 'N'

END