通过拼接的TAG_NAME字符串获取对应的TAG_ID字符串
形如: '丹药|练功流|轻松|学生|学院风' 查询结果:'10|35|36|40'
SELECT GROUP_CONCAT(TAG_ID SEPARATOR '|') TAGS from BOOK_TAG WHERE instr('丹药|练功流|轻松|学生|学院流',TAG_NAME)
将父类别对应的SUMMARY字段同步到子类别的SUMMARY字段
UPDATE BOOK_TYPE SET SUMMARY = (SELECT * FROM (SELECT SUMMARY FROM BOOK_TYPE WHERE TYPE_ID =19) T) where PARENT_TYPE_ID=19;
创建触发器,插入前更新排序值
CREATE TRIGGER t_addsort_rank_b BEFORE INSERT ON RANK FOR EACH ROW
BEGIN
IF NEW.SORT IS NULL
THEN
SET NEW.SORT = 1 + (
SELECT
*
FROM
(
SELECT
IFNULL(MAX(SORT), 1)
FROM
RANK
WHERE
RANK_TYPE_ID = NEW.RANK_TYPE_ID
) T
);
END IF;
END;
MariaDB 查询缓存
缓存大小
set @@global.query_cache_size=1048576;
未完待补充