W
W
wizi2017-08-07 16:40:24
JavaScript
wizi, 2017-08-07 16:40:24

How to execute SELECT and then DELETE in one query?

The task is to delete a line and, as a result, display all the fields of the deleted line.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
miroshacat, 2019-07-08
@miroshacat

var red, green, blue;
function makeColorString() {
red = prompt('Введите насыщенность красного в виде числа от 0 до 255', 255);
blue = prompt('Введите насыщенность синего в виде числа от 0 до 255',0);
function checkInput(i) {
  i = Number(i);
var bgValue = 'rgb(' + i+ ', ' + green + ', ' + blue + ')';
console.log(bgValue);
i = Number(i);


if (isNaN(i)) {
  i = prompt('В качестве значения насыщенности цвета вы ввели не число. Пожалуйста, введите число от 0 до 255.');
  i = Number(i);
}
else if (i < 0) {
  i = 0;
  console.log('Наименьшее из возможных чисел — ноль, мы подставили значение 0.');
}
else if (i > 255) {
  i = 255;
  console.log('Наибольшее возможное число — 255, мы подставили его.');
}
  else{
    console.log('Вы определили насыщенность цвета как ' + i);
}}

console.log(red+green+blue);
console.log(isNaN(red)); 
  makeColorString();}

B
Boris Korobkov, 2017-08-07
@BorisKorobkov

On pure SQL - only two separate requests.
You can write a trigger "... before delete on each row ... old. ...", for example, to write to the log table.
https://dev.mysql.com/doc/refman/5.7/en/trigger-sy...

A
aynur_safin, 2017-08-07
@aynur_safin

How to execute SELECT and then DELETE in one query?

To perform a SELECT and then a DELETE in the same query, you need to put them in a procedure.

H
HrTm, 2017-08-10
@HrTm

Use Output ... Delete
to insert into a table:

DELETE FROM dbo.t1  
OUTPUT DELETED.* INTO dbo.t2 
WHERE id = someid

or simply:
DELETE FROM dbo.t1  
OUTPUT DELETED.*
WHERE id = someid

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question