MYSQL5.8-----3
666666666666666666666666
如多带有通配符的,要使用一下格式 select * from user where usename like "%1\%" ESCAPE 1; 再通配符前面使用1 后面加上ESCAPE告诉1 是不用解析的
注意:上面的FOWER是错的,改为POWER
注意:这些要配合表来进行操作:
#函数不能重名!!!!!!!!!!!!,函数不能重名
自定义带参数的函数,结合delimiter修改结束符号
mysql> select * from class; +----+-----------+ | id | classname | +----+-----------+ | 1 | dada | | 2 | jave | | 3 | javed | | 4 | py | +----+-----------+ 4 rows in set (0.00 sec) mysql> DELIMITER // mysql> CREATE FUNCTION add_class(class VARCHAR(20)) RETURNS INT UNSIGNED BEGIN INSERT class(classname) VALUES(class); -> RETURN LAST_INSERT_ID(); -> END -> // Query OK, 0 rows affected (0.37 sec) mysql> DELIMITER ; mysql> SELECT add_class("jaja"); +-------------------+ | add_class("jaja") | +-------------------+ | 8 | +-------------------+ 1 row in set (0.01 sec) mysql> SELECT * FROM class; +----+-----------+ | id | classname | +----+-----------+ | 1 | dada | | 2 | jave | | 3 | javed | | 4 | py | | 8 | jaja | +----+-----------+ 5 rows in set (0.00 sec) mysql>