P
P
Python Newbie2021-10-20 10:07:44
SQLite
Python Newbie, 2021-10-20 10:07:44

How to change last column in sqlite python?

I have a sqlite table and I need to change a value in it. The thing is, I have multiple rows with the same key. How can I change only the last line with the hello key?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vindicar, 2021-10-20
@Vindicar

> The fact is that I have several rows with the same key.
So you do not have a primary key in the table, since the primary key must be unique.
Correct the structure of the table so that there is a truly unique key, then there will be no such problems.

R
Ronald McDonald, 2021-10-20
@Zoominger

The matter is that at me some lines with the same key. How can I change only the last line with the hello key?

Suck all records with this key;
Sort by id;
Select the first entry.
Clue:
SELECT * FROM my_table WHERE my_key='Hello wrot' ORDER BY 'id' DESC LIMIT 1;

I can’t vouch for pronunciation, that’s why it’s a hint, not a ready-made answer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question