select * from tfl where find_in_set(pid,'1,2');
+----+----------+-----+
| id | category | pid |
| 3 | 化妆品 | 1 |
| 4 | 洗漱品 | 1 |
| &nbs
这个函数会将搜索到的字段值,用逗号连接起来
mysql> select group_co
ncat(pid) from tfl;
+-------------------+
| group_concat(pid) |
| 0,0,1,1,3,3,2,7 |
1 row in set
函数作用,函数中个字段连接起来
mysql> select * from tfl;
| 1 | 洗化 | 0 |
| 2 | 日杂 | 0 |
| &n
创建函数
CREATE FUNCTION getChildLst(rootId INT)
RETURNS varchar(1000)
BEGIN
DECLARE sTemp VARCHAR(1000)
创建一个function getChildLst, 得到一个由所有子节点号组成的字符串.
mysql> delimiter //mysql>mysql> CREATE FUNCTION `getChildLst`(rootId INT)
DECLARE sTemp VARCHAR(1000);
DECLARE sTempChd VARCHAR(1000);
SET sTemp = '$';
SET sTempChd =cast(rootId as CHAR);
WHILE sTempChd
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50540
Source Host : localhost:3306
Source Database &nb
不需要再写这句话了,这句话在创建向导中配置。
注意导出语句后面没有分号,但是进入mysql后的sql语句是有的。
like是广泛的模糊匹配,字符串中没有分隔符,Find_IN_SET 是精确匹配,字段值以英文”,”分隔
mysql> select find_in_set ('b','a,b,c,d');