If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Update data from another Table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-23-03, 20:43
hsuzuki hsuzuki is offline
Registered User
 
Join Date: Dec 2003
Posts: 1
Update data from another Table

I am trying to update a field in one table - based on data stored in another table and was wondering what the SQL statement may look like ?
I used
update inventoryADG
set inventotyADG.ListPrice = (select inventory.user3
from inventory
where inventory.user3<>0)

but it doesn't work
Anyway, any help would be appreciated.
Reply With Quote
  #2 (permalink)  
Old 12-23-03, 21:07
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,618
What is the error it is reporting back? IS it that the subquery returned more then one result??
Reply With Quote
  #3 (permalink)  
Old 12-24-03, 19:01
sbaru sbaru is offline
Registered User
 
Join Date: Jun 2003
Location: Ohio
Posts: 148
Re: Update data from another Table

I would imagine you might want to join the table in the main query and the sub query. If that is what you want try this

update inventoryADG
set inventotyADG.ListPrice = inventory.user3
from inventory, inventoryADG
where inventory.user3<>0
and ...............

Quote:
Originally posted by hsuzuki
I am trying to update a field in one table - based on data stored in another table and was wondering what the SQL statement may look like ?
I used
update inventoryADG
set inventotyADG.ListPrice = (select inventory.user3
from inventory
where inventory.user3<>0)

but it doesn't work
Anyway, any help would be appreciated.
Reply With Quote
  #4 (permalink)  
Old 12-24-03, 20:06
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
The problem is that the query

select inventory.user3
from inventory
where inventory.user3<>0

is returning more than 1 record. You need to post the schema for both tables and be more specific what you are trying to update.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On