A
A
assx642017-02-16 03:26:36
MySQL
assx64, 2017-02-16 03:26:36

How to set increment by one in MySql string?

Actually such a question. We have a table in which, for the same name match (say, in the name_1 varchar column), the i++ of the column (name_2 int / varchar) should occur.
When filling out the form:
name_1(user enters a name): Andrey, Andrey, Andrey, Andrey.
name_2 (the user enters the number 1, or 2, for example, if he fills out the form again): 1,1,1,1 It is
necessary that the request change name_2 to: 1,2,3,4 (if the values ​​​​in name_1 are identical)
The request itself was, but stuck:
This line is not suitable, i.e. adds value +1 in all columns: SET name_2 = name_2 + 1
Which makes name_2 become: 2,2,2,2.
Is it just cycles?
Can someone tell me how to change this part of the request?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2017-02-16
@MoonMaster

Perhaps you should use COALESCE and MAX??

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question