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.
Author |
Topic |
amit120k
Starting Member
16 Posts |
Posted - 2013-08-02 : 08:00:50
|
tbl1ItemType ItemID----------------a 1b 2c 3tbl2ItemType ItemCount----------------a NULLb NULLTake count of a and b from tbl1 and update that to tbl2 in single Query. |
|
stepson
Aged Yak Warrior
545 Posts |
Posted - 2013-08-02 : 08:17:26
|
[code]update ASET A.itemCount=B.cItemIDfrom tbl1 Ainner join(select itemType,count(itemID) as cItemIDfrom tbl1group by itemType)B on A.itemType=B.itemType[/code]SCe-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mutsabinWeb |
|
|
stepson
Aged Yak Warrior
545 Posts |
Posted - 2013-08-02 : 09:13:53
|
[code]update ASET A.itemCount=B.cItemIDfrom tbl2 as Ainner join(select itemType,count(itemID) as cItemIDfrom tbl1group by itemType)B on A.itemType=B.itemType[/code]at A it's tbl2 not tbl1Ce-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mutsabinWeb |
|
|
amit120k
Starting Member
16 Posts |
Posted - 2013-08-03 : 13:01:16
|
Hey the solution worked for me..thanks dude... |
|
|
stepson
Aged Yak Warrior
545 Posts |
Posted - 2013-08-03 : 14:50:35
|
with welcomeCe-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mutsabinWeb |
|
|
|
|
|