CREATE PROCEDURE testP4(
in a INT,in b INT,OUT c INT,OUT d INT
)
BEGIN
SET c = a+b;
SELECT COUNT(Attribution) into d FROM credit_card;
END
CALL testP4(1,2,@s,@m);
SELECT @s,@m;
MySQL大数据量分页性能优化
SELECT * FROM product a JOIN (select id from product limit 866613, 20) b ON a.ID = b.id
给表添加更新时间字段
ALTER TABLE `tableName` ADD `updateAt` TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP;
修改秒杀开始结束时间
update seckill.seckill a SET a.end_time = date_sub(NOW(),interval -2 day) -- 具体可搜索mysql日期时间函数
简单触发器示例
CREATE TRIGGER lasttime
AFTER UPDATE ON myaccount.credit_card
FOR EACH ROW
BEGIN
UPDATE seckill SET a=1 WHERE id = new/old.id ;
END;
new是新添加行数据的指代,old是修改前的行数据指代