L
L
LazariusPaskalius2020-07-04 16:24:25
SQL
LazariusPaskalius, 2020-07-04 16:24:25

How to delete the first matching row of a table?

It is necessary to delete the first row of the table that matches the criteria. It is the first one, because there may be records that also satisfy this condition, but with a different id (it is not possible to specify id as a parameter).
How can I do that?
Example:

id    name   age
1      Bob     23
2      Bob    23


Only the first line needs to be removed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-stream, 2020-07-04
@d-stream

delete from table where id in (select top 1 id from table where <нужное условие>)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question