view sourceprint?
網站建設哪家好,找創新互聯公司!專注于網頁設計、網站建設、微信開發、小程序開發、集團企業網站建設等服務項目。為回饋新老客戶創新互聯還提供了邗江免費建站歡迎大家使用!
01.
DELIMITER ;
02.
03.
DROP FUNCTION IF EXISTS urlencode;
04.
05.
DELIMITER |
06.
07.
CREATE FUNCTION urlencode (s VARCHAR(4096)) RETURNS VARCHAR(4096)08.
DETERMINISTIC
09.
CONTAINS SQL
10.
BEGIN
11.
DECLARE c VARCHAR(4096) DEFAULT '';
12.
DECLARE pointer INT DEFAULT 1;
13.
DECLARE s2 VARCHAR(4096) DEFAULT '';
14.
15.
IF ISNULL(s) THEN
16.
RETURN NULL;
17.
ELSE
18.
SET s2 = '';
19.
WHILE pointer = length(s) DO
20.
SET c = MID(s,pointer,1);
21.
IF c = ' ' THEN
22.
SET c = '+';
23.
ELSEIF NOT (ASCII(c) BETWEEN 48 AND 57 OR24.
ASCII(c) BETWEEN 65 AND 90 OR
25.
ASCII(c) BETWEEN 97 AND 122) THEN
26.
SET c = concat("%",LPAD(CONV(ASCII(c),10,16),2,0));27.
END IF;
28.
SET s2 = CONCAT(s2,c);
29.
SET pointer = pointer + 1;
30.
END while;
31.
END IF;
32.
RETURN s2;
33.
END;
34.
|
35.
DELIMITER ;
view sourceprint?
01.
DROP FUNCTION IF EXISTS urldecode;
02.
03.
DELIMITER |
04.
05.
CREATE FUNCTION urldecode (s VARCHAR(4096)) RETURNS VARCHAR(4096)06.
DETERMINISTIC
07.
CONTAINS SQL
08.
BEGIN
09.
DECLARE c VARCHAR(4096) DEFAULT '';
10.
DECLARE pointer INT DEFAULT 1;
11.
DECLARE h CHAR(2);
12.
DECLARE h1 CHAR(1);
13.
DECLARE h2 CHAR(1);
14.
DECLARE s2 VARCHAR(4096) DEFAULT '';
15.
16.
IF ISNULL(s) THEN
17.
RETURN NULL;
18.
ELSE
19.
SET s2 = '';
20.
WHILE pointer = LENGTH(s) DO
21.
SET c = MID(s,pointer,1);
22.
IF c = '+' THEN
23.
SET c = ' ';
24.
ELSEIF c = '%' AND pointer + 2 = LENGTH(s) THEN25.
SET h1 = LOWER(MID(s,pointer+1,1));
26.
SET h2 = LOWER(MID(s,pointer+2,1));
27.
IF (h1 BETWEEN '0' AND '9' OR h1 BETWEEN 'a' AND 'f')28.
AND
29.
(h2 BETWEEN '0' AND '9' OR h2 BETWEEN 'a' AND 'f')30.
THEN
31.
SET h = CONCAT(h1,h2);
32.
SET pointer = pointer + 2;
33.
SET c = CHAR(CONV(h,16,10));
34.
END IF;
35.
END IF;
36.
SET s2 = CONCAT(s2,c);
37.
SET pointer = pointer + 1;
38.
END while;
39.
END IF;
40.
RETURN s2;
41.
END;
42.
43.
|
44.
45.
DELIMITER ;
當一個字符串經過多次 urlencode 處理之后,可以使用 multiurldecode來解碼,它將多次調用 urldecode來解碼,直到沒有需要解碼的字符
view sourceprint?
01.
DELIMITER ;
02.
03.
DROP FUNCTION IF EXISTS multiurldecode;
04.
05.
DELIMITER |
06.
07.
CREATE FUNCTION multiurldecode (s VARCHAR(4096)) RETURNS VARCHAR(4096)08.
DETERMINISTIC
09.
CONTAINS SQL
10.
BEGIN
11.
DECLARE pr VARCHAR(4096) DEFAULT '';
12.
IF ISNULL(s) THEN
13.
RETURN NULL;
14.
END IF;
15.
REPEAT
16.
SET pr = s;
17.
SELECT urldecode(s) INTO s;
18.
UNTIL pr = s END REPEAT;
19.
RETURN s;
20.
END;
21.
22.
|
23.
24.
DELIMITER ;
這個要看你具體的記錄是創建日期的格式是人什么樣的,假如,你的記錄的是 unix 時間戳,
SELECT * FROM t WHERE (unix_timestamp(NOW()) - create_time) 300;
可以直接精確查詢:
select * from test where name ='%a' -------------查詢name為 %a的數據
模糊查詢 select * from test where name like '%\%a%'; -----------模糊查詢name中包含 %a的數據
分享名稱:mysql怎么精確查找 mysql如何查找數據
當前地址:http://m.newbst.com/article14/dogoode.html
成都網站建設公司_創新互聯,為您提供靜態網站、響應式網站、定制網站、外貿網站建設、動態網站、自適應網站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯