Reputation: 49
I have two tables as below:
abc
:
id
icon
timestamp
xyz
:
id
dob
abcId
icon
timestamp
i want to update a icon
value in xyz
table with specific id
. For this i am using below query.
update xyz t set image = (select image from abc t1 where id = t.abcId);
But this update all the values. Can any one please update this.
Upvotes: 2
Views: 110
Reputation: 1157
I suggest this query:
update xyz t
set image =
(select image from abc t1 where t1.id = t.abcId)
where t.id="**ID That You Want To Update**";
Upvotes: 1
Reputation: 247950
You forgot to add a WHERE
clause to the UPDATE
statement, that's why all rows are updated.
Try adding the following at the end of the statement:
WHERE t.id = 42
Then only the xyz
with id
42 will be updated.
Upvotes: 2