R
R
redduckrobot2017-08-03 20:41:05
Django
redduckrobot, 2017-08-03 20:41:05

How to remove missing id from list from database?

Hello, I can’t find a concise solution to such a problem:
There are tables in the database with such id [1, 2, 3], for example. They come from outside [1, 5]. You need to add the 5th, but the missing ones (for example, this is id - 2) should be deleted. Tell me, please, is it possible to do this and how, without completely rewriting the table?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2017-08-03
@dimonchik2013

delete from tablename where id in (2)
via ORM is even easier

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question