简体   繁体   English

使用angularjs php和mysql的字母数字自动增量ID

[英]alphanumeric auto increment id using angularjs php and mysql

单击此处获取用户界面 interface 接口

I have an interface implemented using angularjs, php and database is mysql and there I have a field call hop reference Ex:- 7G/0001 the 1st part is the frequency and a slash and the frequency should be the selected one from the combo box and the other part should be auto increment in the database for an example the next one could be 8G/0002. 我有一个使用angularjs,php和database实现的接口是mysql,并且我有一个现场呼叫跃点参考例如:7G / 0001第一部分是频率和斜杠,频率应是从组合框中选择的一个,另一部分应该是数据库中的自动递增,例如下一个可能是8G / 0002。 How do I implement this using angularjs, php and mysql. 我如何使用angularjs,php和mysql实现此功能。

Thanks 谢谢

One way to do this is to store two different fields: frequency and id. 一种方法是存储两个不同的字段:频率和ID。 Then in your queries, concatenate the values together. 然后在查询中将这些值连接在一起。 By using the auto increment field, you avoid any possibility of duplicate values or concurrency issues. 通过使用自动递增字段,可以避免重复值或并发问题的任何可能性。

Example

CREATE TABLE ees.foo (
   frequency VARCHAR(2) NOT NULL,
   id INT AUTO_INCREMENT NOT NULL
);

Sql query SQL查询

SELECT concat(frequency,'/',lpad(id, 4, '0')
  FROM tbl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM