• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

SQL Query returning more than one value

I need help with an update similar to something like this (I am totally oversimplifying but I think it explains my problem):

Table #1
Number    Data
1              
2
3

Table #2
Number   Data
1             Stuff
2             Different Stuff
3             Something Different

I want to populate the first table with the data from the second table but when I do an update something like

Update Table#1
set table#1.data = (select table#2.date from table#2)
where ......

I get the error returning more then one value.  I understand why it doesn't work, but does anyone have any suggestions?

Thank you
0
MercyHousing
Asked:
MercyHousing
1 Solution
 
Ephraim WangoyaCommented:

Update Table#1
set table#1.data = (select table#2.data from table#2 where Table#1.Number=Table#2.Number)
0
 
knightEknightCommented:
update table1
set data = T2.data
from table1 T1
join table2 T2
  on T1.Number = T2.Number
0
 
MercyHousingAuthor Commented:
Thank you, that did it.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now