Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 10th, 2003, 10:35 AM
gooky gooky is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 gooky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Update ... from ...

Hello.

I am a little lost... in the use of update ... from ...

Let us assume I have something like this:

UPDATE parts SET id_geometry = b.id_geometry_duplicate
FROM
parts a
INNER JOIN fn_duplicate_parts(@id_project) b ON a.id_part = b.id_part_org

How does this query know which rows it needs to update? I can see no relationsship between the tables parts and b (which by accident is also parts). I only want to update those rows in parts where id_part is in b(as id_part_org). I guess it is my lack of knowledge, but really I cannot see the logic in this.

Could anyone clarify?

Thanks in advance,

Lasse Johansen

Reply With Quote
  #2  
Old October 11th, 2003, 02:49 PM
unatratnag unatratnag is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 312 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 6 sec
Reputation Power: 6
Send a message via AIM to unatratnag
when you say inner join it's kind of like making it one table on the ON part, so if your tables are
Code:
A
circle          12
square         13
rhombus         9

B
square        15
rhombus      15
BlackSabbath 666


the inner join on makes them equal on id, in this case lets say id is the circle, square rhombus name portion

so our table after the inner join is this
Code:
A.square   A.12  B.square   B.15
A.rhombus  A.13  B.rhombus B.15

and you're setting A. price equal to B.price, so it turns into
Code:
square   15  square   15
rhombus  15  rhombus 15

so your final A table is
Code:
A
circle          12
square       15
rhombus       15

Reply With Quote
  #3  
Old October 12th, 2003, 12:20 PM
gooky gooky is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 gooky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Actually this is not my concern... My concern is how can parts a(in FROM(SELECT) clause) refer to parts(in UPDATE clause)

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Update ... from ...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT