Home  >  Q&A  >  body text

mysql 中 实现字段值为BOX001,BOX002.... 每插入一条数据数字部分自增

mysql 中 实现字段值为BOX001,BOX002.... 每插入一条数据数字部分自增

高洛峰高洛峰2742 days ago610

reply all(5)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 16:18:49

    If you want to try sequence, you can check out the link description of this article

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 16:18:49

    This kind of logic is better handled by a program (php or py)

    reply
    0
  • 迷茫

    迷茫2017-04-17 16:18:49

    It is recommended to handle it in the business logic layer of the development language

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 16:18:49

    If you do not consider number jumps, the simplest way is to create two fields, one field to save the BOX, one field to be the auto-increment, and two fields to be used as
    Usually this encoding is to be displayed, so When writing a program, you only need simple splicing and formatting.
    If there are complex logic checksums and higher requirements, it is recommended to write them in the business logic layer.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 16:18:49

    In mysql, provide an idea. You can split this and store it in two fields. The prefix BOX is a field, and the following number is a field (num) 001. Then every time you insert data, it is fetched from this table. The table header (BOX) is concatenated with the following number (num) column. After inserting the data, remember to change the num column + 1 according to the prefix. It's a bit like the order number generation rules we did before.

    reply
    0
  • Cancelreply