Thread: Sql help
View Single Post

   
  #4 (permalink)  
Old 02-27-2008, 06:28 AM
Bob Stearns
 
Posts: n/a
Default Re: Sql help

vp wrote:
> PK1 STATE1 PROV1 PLAN1
> pk2 state2 prov2 plan2
>
>
> If (STATE1=state2 and PROV1=prov2 ) than take pk2 to plug in to
> another field
> Should I do a self join on the table to check this condition??? or
> please advice
>
> thanks,
>

As Joe Celko often says, some DDL would help, but here's a guess based
on my best guess based on what little data I have.

Perhaps you want something like:

UPDATE some_other_table SET some_column=(
SELECT pk FROM first_table
WHERE state='state2'
AND province='prov2')
Reply With Quote