Reputation: 159
I want to update just one selected column in MS Access 2010. But when I use below update query
MS Access update all tarih
column values. When I just write the below Select query, it works right. But when I use it in nested update query Update query update all tarih
column values. What can I do?
UPDATE words
SET tarih='12'
WHERE
tarih = (SELECT FIRST(tarih)
FROM words
WHERE tarih='11')
Upvotes: 1
Views: 2431
Reputation: 97131
That sample query should have the same affect as this one:
UPDATE words SET tarih='12'
WHERE tarih = '11';
In plain English, it will change tarih
to 12 in all rows where tarih
is 11. However, if your words
table contains multiple rows where tarih
is 11, and you want tarah
changed to 12 in only one of those rows, you need a way to tell the database which one of those rows it should update.
For example, if your words
table includes an autonumber primary key field named id
, the following query should do what you want.
UPDATE words SET tarih='12'
WHERE id = DMin("id", "words", "tarih='11'");
Try a similar approach adapted to your actual words
table. You don't actually need to use an autonumber field. Another type of primary key field could be used instead. If your table does not include a primary key consider adding one. Without a primary key, you could use a combination of fields to uniquely identify which row should be updated. But if there is no combination of fields which uniquely identifies each row, you won't be able to UPDATE
only the "first" of several matches.
Upvotes: 1