其实获得当前日期的年月日时分秒+6位随机流水号即可,这样基本不会重复
就不用判断插入值的大小啦,只获取年月日+3位数还得判断一下,当然如果考虑数据库存储和读取效率另说啦
就不用判断插入值的大小啦,只获取年月日+3位数还得判断一下,当然如果考虑数据库存储和读取效率另说啦
2017-03-19
最好加上else ,防止空值
SELECT
sum(CASE WHEN use_name = "沙僧"
THEN b.kills
ELSE 0 END) AS '沙僧',
sum(CASE WHEN use_name = "猪八戒"
THEN b.kills
ELSE 0 END) AS '猪八戒'
FROM im_user AS a
INNER JOIN im_kill AS b ON b.user_id = a.id;
SELECT
sum(CASE WHEN use_name = "沙僧"
THEN b.kills
ELSE 0 END) AS '沙僧',
sum(CASE WHEN use_name = "猪八戒"
THEN b.kills
ELSE 0 END) AS '猪八戒'
FROM im_user AS a
INNER JOIN im_kill AS b ON b.user_id = a.id;
2017-03-19
UPDATE order_seq SET order_sn = order_sn + v_cnt WHERE timestr = v_timestr;
IF ROW_COUNT() = 0 THEN
INSERT INTO order_seq(timestr,order_sn) VALUES(v_timestr,v_cnt);
END IF;
SELECT CONCAT(v_timestr,LPAD(order_sn,7,0))AS order_sn
FROM order_seq WHERE timestr = v_timestr;
COMMIT;
IF ROW_COUNT() = 0 THEN
INSERT INTO order_seq(timestr,order_sn) VALUES(v_timestr,v_cnt);
END IF;
SELECT CONCAT(v_timestr,LPAD(order_sn,7,0))AS order_sn
FROM order_seq WHERE timestr = v_timestr;
COMMIT;
2017-01-07