mysql数据库创建流水号 CREATE TRIGGER saledetail_id BEFORE INSERT ON saledetail FOR EACH ROW BEGIN declare n int; select IFNULL(max(right(ItemID,4)),0) into n from saledetail where mid(ItemID,1,8)=DATE_FORMAT(CURDATE(),'%Y%m%d'); set NEW.ItemID=concat(DATE_FO
数据库存储过程 drop PROCEDURE generate_serial_number; CREATE PROCEDURE generate_serial_number( ), IN param_org_id bigint, OUT result bigint) begin START TRANSACTION; select number into result from sys_serial_number where table_key=param_key and org_id = par
第一种方法: select (@i:=@i+1) as i,table_name.* from table_name,(select @i:=0) as it 第二种方法: set @rownum=0;select @rownum:=@rownum+1 as rownum, t.username from auth_user t limit 1,5;
方法1: SELECT @rownum :=@rownum + 1 AS rownum, t.* FROM integral_system_user t, (SELECT @rownum := 0) AS R; 例子: SELECT @ROWNUM :=@ROWNUM + 1 AS "ID", TB.* FROM ( SELECT c.`name` AS "编队名称", c.id AS "编队ID", b.user_id AS "用户I
一.show相关命令语句 1.查看表的索引 show index from tbl_name; 1 table:表名 non_unique:索引是非唯一的?.0否,唯一是索引的.1是,是非唯一索引.(ps:这让我想起了令我自挂东南枝的英语) key_name:索引名称 seq_in_index: 索引中的起始序列号 column_name:创建索引的名称 collation:列以什么形式存储在索引中,A升序,null不排序 2.显示系统变量 show session variables [lik
mysql数字加减科学计数法 这两天因为需求,需要获取一张表的流水号.规则是这样的.当前日期+8位流水号.比如:2015062400000001,2015062400000002,2015062400000003.... 因为考虑到并发问题,所以解决的方案是:在MySQL写存储过程,逻辑如下: 1.查询表今天流水号的最大主键值:如: SELECT MAX(a.ORDER_ID) from Zhang_Test a where 1=1 and a.order_id LIKE CONCAT('%',