先是測試表
成都創(chuàng)新互聯(lián)專注于興隆企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,成都做商城網(wǎng)站。興隆網(wǎng)站建設(shè)公司,為興隆等地區(qū)提供建站服務(wù)。全流程按需求定制開發(fā),專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,成都創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)
三列,自動增長id,name,以及datetime
mysql CREATE TABLE test123 (
- `id` INT AUTO_INCREMENT PRIMARY KEY,
- `name` VARCHAR(10),
- `datetime` DATETIME
- );
Query OK, 0 rows affected (0.06 sec)
插入數(shù)據(jù)
mysql INSERT INTO test123 (`name`, `datetime`)
- VALUES('Hello', '2011-04-22 21:18:00');
Query OK, 1 row affected (0.03 sec)
查詢結(jié)果
mysql select * from test123;
+----+-------+---------------------+
| id | name | datetime |
+----+-------+---------------------+
| 1 | Hello | 2011-04-22 21:18:00 |
+----+-------+---------------------+
1 row in set (0.02 sec)
CREATE?DEFINER?=?CURRENT_USER?PROCEDURE?`NewProc`(IN?`username`?varchar,IN?`passwords`?varchar)
BEGIN
INSERT?INTO?test_user?(Username,Passwords)?VALUES?(username,?passwords);
END;
以下只是個例子
CREATE procedure test
@n1 char(10),
@n2 char(10),
@n3 char(10),
@n4 char(10),
@n5 char(10),
@n6 char(10),
@n7 char(10),
@n8 datetime,
@n9 datetime,
@n10 int
as
select * --------這部分請將傳入的參數(shù)帶入查詢的條件中
from table1 t1,table2 t2,table3 t3
where deldate between @n8 and @n9
and t1.ponum = t2.ponum
and t2.partnum = t3.partnum
and t3.layer =@n1
GO
CREATE FUNCTION `fristPinyin`(P_NAME VARCHAR(255)) RETURNS varchar(255) CHARSET utf8
BEGIN
DECLARE V_RETURN VARCHAR(255);
SET V_RETURN = ELT(INTERVAL(CONV(HEX(left(CONVERT(P_NAME USING gbk),1)),16,10),
0xB0A1,0xB0C5,0xB2C1,0xB4EE,0xB6EA,0xB7A2,0xB8C1,0xB9FE,0xBBF7,
0xBFA6,0xC0AC,0xC2E8,0xC4C3,0xC5B6,0xC5BE,0xC6DA,0xC8BB,
0xC8F6,0xCBFA,0xCDDA,0xCEF4,0xD1B9,0xD4D1),
'A','B','C','D','E','F','G','H','J','K','L','M','N','O','P','Q','R','S','T','W','X','Y','Z');
RETURN V_RETURN;
END
pinyin :此函數(shù)是將一個中文字符串對應(yīng)拼音母的每個相連 (例如:"中國人"-ZGR)
復(fù)制代碼 代碼如下:
CREATE FUNCTION `pinyin`(P_NAME VARCHAR(255)) RETURNS varchar(255) CHARSET utf8
BEGIN
DECLARE V_COMPARE VARCHAR(255);
DECLARE V_RETURN VARCHAR(255);
DECLARE I INT;
SET I = 1;
SET V_RETURN = '';
while I LENGTH(P_NAME) do
SET V_COMPARE = SUBSTR(P_NAME, I, 1);
IF (V_COMPARE != '') THEN
#SET V_RETURN = CONCAT(V_RETURN, ',', V_COMPARE);
SET V_RETURN = CONCAT(V_RETURN, fristPinyin(V_COMPARE));
#SET V_RETURN = fristPinyin(V_COMPARE);
END IF;
SET I = I + 1;
end while;
IF (ISNULL(V_RETURN) or V_RETURN = '') THEN
SET V_RETURN = P_NAME;
END IF;
RETURN V_RETURN;
END
示例:
復(fù)制代碼 代碼如下:
mysql select p.province, fristPinyin(p.province), pinyin(p.province) from province p;
+------------------+-------------------------+--------------------+
| province | fristPinyin(p.province) | pinyin(p.province) |
+------------------+-------------------------+--------------------+
| 北京市 | B | BJS |
| 天津市 | T | TJS |
| 河北省 | H | HBS |
| 山西省 | S | SXS |
| 內(nèi)蒙古自治區(qū) | N | NMGZZQ |
+------------------+-------------------------+--------------------+
5 rows in set
分享標(biāo)題:mysql語句入?yún)⒃趺磳?mysql刪除語句怎么寫
轉(zhuǎn)載注明:http://jinyejixie.com/article30/hojepo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、企業(yè)網(wǎng)站制作、企業(yè)建站、全網(wǎng)營銷推廣、搜索引擎優(yōu)化、網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)