Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > Need help on a update sql with a join state
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 10th April 23:38
mark mcgrath
External User
 
Posts: 1
Default Need help on a update sql with a join state



Hello,

I am realy struggling with this.
I need to update a feild in one table based on the value
of a feild in another table
I have SQL server 2000

Example: goes something like this.

IF F4101.IMSTKT = 'U'
SET F4102.IBSTKT = 'U'
JOIN ON F4101.imitm = f4102.ibitm

Thank you,

In advance for your help.

Mark mcgrth
  Reply With Quote


  sponsored links


2 10th April 23:38
i_am_don_and_you?
External User
 
Posts: 1
Default Need help on a update sql with a join state



Here is the example. Here I am taking up two tables xt1 and xt2. Both have
primary key "id". The purpose is to update the name field of xt1 if the
grade field of xt2 = 'a' and xt1.id = xt2.id.

create table xt1
(
id int,
name varchar(10)
)

insert into xt1 values (1, 'abc')
insert into xt1 values (2, 'xyz')
insert into xt1 values (3, 'aaa')
insert into xt1 values (4, 'bbb')
insert into xt1 values (5, 'ccc')
insert into xt1 values (6, 'xdz')

create table xt2
(
id int,
grade varchar(10)
)

insert into xt2 values (1, 'b')
insert into xt2 values (2, 'b')
insert into xt2 values (3, 'c')
insert into xt2 values (4, 'a')
insert into xt2 values (5, 'a')
insert into xt2 values (6, 'a')

select * from xt1
select * from xt2

update xt1
set xt1.name = xt1.name + ' I am changed'
from xt1 inner join xt2
on xt1.id = xt2.id
where xt2.grade = 'a'
  Reply With Quote
3 10th April 23:38
mark mcgrath
External User
 
Posts: 1
Default Need help on a update sql with a join state


and xt2. Both have

of xt1 if the
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666