Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 update full table

Author  Topic 

pascal_jimi
Posting Yak Master

167 Posts

Posted - 2015-02-11 : 02:38:32
hi friends

i have one problem for update table

have two table

declare @t1 table
(id int not null identity(1,1),
shesab int null,
phone int null)

insert into @t1
select 54000,null
union all
select 55000,null
union all
select 56000,null
select*from @t1

declare @t2 table
(id int not null identity(1,1),
shesab int null,
phone int null)
insert into @t2
select 54000,300
union all
select 54000,500
union all
select 54000,600
union all
select 55000,600
union all
select 55000,800
union all
select 56000,600
union all
select 56000,100
union all
select 56000,900
select*from @t2


(????? ??????????: 3)
id shesab phone
----------- ----------- -----------
1 54000 NULL
2 55000 NULL
3 56000 NULL

(????? ??????????: 3)

(????? ??????????: 8)

id shesab phone
----------- ----------- -----------
1 54000 300
2 54000 500
3 54000 600
4 55000 600
5 55000 800
6 56000 600
7 56000 100
8 56000 900

(????? ??????????: 8)



problem hier this

i need update column phone in @t1 table where @t1.shesab=@t2.shesab

but every shesab in have a 2-3 phone in @t2 table me need also one phone from @t2 table


for example need result table from update

id shesab phone
----------- ----------- -----------
1 54000 500
2 55000 800
3 56000 900



http://sql-az.tr.gg/

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2015-02-11 : 05:03:00
why 500 for 54000?


Too old to Rock'n'Roll too young to die.
Go to Top of Page
   

- Advertisement -