I need to create a sequence of equal numbers within two columns in the bank

Asked

Viewed 20 times

0

Hello guys I’m new with mysql code manipulation, I need to help to create a numerical sequence in the registration and registration columns, note: the records have to be equal in both columns! Note: I want to repeat the information of the other columns generating the sequence only in initial record and final record, both columns as the same sequence number Thanks in advance!

INSERT INTO tabela ('empresa','nome', 'telefone', 'registro_inicial', 'registro_final', 'id_venda', 'justificativa', 'data_inserido', 'protocolo') 
    VALUES (1, 'Joao', '99999-0000', '', '', 'Venda no crediario', '2020-11-04 15:43:09', NULL);
    WHERE registro_inicial > 000001
    AND registro_final <100000

1 answer

0

I don’t quite understand your question, but looking at it this way you can do that, just replace those empty fields and insert the numbers you want. And take out this Where. Where it is for when Voce from a SELECT, it does not work in Insert. Have to insert and give a SELECT with WHERE to get fields specific records, but there is something else...

[EDIT] After your reply, I understood that you want to do an update and not an Insert, in which case it would be.

UPDATE tabela SET registro_inicial='valor', registro_final='valor2' WHERE registro_inicial > 000001 AND registro_final <100000
  • So I want to keep the records of the other columns and put a numerical sequence in the columns registe_initial and registro_final and through this sequence generate the number of rows according to the sequence set, I do not know if I was clear.

  • Ai Voce has to update and not an Insert. UPDATE NOME_DA_TABELA SET field1 = value1, field2 = value2 WHERE field1 = 'value';

  • So in the update I will duplicate the other information? generating new numbers in sequence in the initial and final registration columns? because not only do I need to change, I need to generate new rows repeating all information from the other columns and new information, only in the initial and final registration columns.

  • in the update the other columns will have the same value. Everything you pass after the set is what you will update. In the case there, initial record and final record where (Where) the initial record greater than 000001 and final record < 100000.

  • I get it, I’m gonna do it here, and I’m gonna warn you

  • Do you want to duplicate the other information? Do you want to insert a new row into the table would that be? In this case there is no simple way to do it. You’d have to use a programming language to make that rule.

  • That’s right, I want to duplicate the other information by inserting new lines, following the sequence set in the two columns starting record > 000001 and end record < 100000

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.