K
K
kirwait2021-10-05 16:00:58
MySQL
kirwait, 2021-10-05 16:00:58

How to fill with ones a string from a specific column to another specific column in mySQL?

Hello, the task is as follows: there is a mysql table, 10 columns: 01, 02 to 10, there is a beginning and end of the event, which are equal to the strings "01", "02", ..., "10" (for example, start at "08", end at "10"), depending on the value of the beginning and end, you need to fill in the plate with ones from the column corresponding to the beginning to the column corresponding to the end, not including the end, that is, if the beginning is at "08", the end is at "10" - you need to fill in previously selected row, column cell 08, 09. (I fill in ones) The
request is sent to the database via the JDBC Template in java

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2021-10-05
@rPman

this is called a pivot table
in mysql (and many others) there are none as part of the syntax of the language, and each generates sql queries according to the situation, using case / if substituting the desired condition under the desired table - this is for output (i.e. in select) respectively you cannot create such tables, you have to simulate them by placing the columns as 1-to-M records in one table.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question