M
M
mt. NATS2019-12-16 11:16:19
SQL
mt. NATS, 2019-12-16 11:16:19

How can I make such a request?

Please help me make a request!
There are four columns: X, L1, L2, L3
I would like to do the following in one query, if possible - when adding a new record,
only the value for X is specified,
which can be one of 3 possible options - L1, L2, L3,
one of them, whose name=X gets 0,
the rest +1 to the value from the previous entry...
as I understand it, triggers need to be applied here, but I can’t figure out how

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2019-12-16
@Dimastik86

"Previous entry":

SELECT * FROM tbl ORDER BY id DESC LIMIT 1 OFFSET 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question