189 8069 5689

mysql语句入参怎么写,mysql删除语句怎么写

一句简单的MySql插入语句怎么写

先是测试表

成都创新互联专注于兴隆企业网站建设,成都响应式网站建设公司,成都做商城网站。兴隆网站建设公司,为兴隆等地区提供建站服务。全流程按需求定制开发,专业设计,全程项目跟踪,成都创新互联专业和态度为您提供的服务

三列,自动增长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)

插入数据

mysql INSERT INTO test123 (`name`, `datetime`)

- VALUES('Hello', '2011-04-22 21:18:00');

Query OK, 1 row affected (0.03 sec)

查询结果

mysql select * from test123;

+----+-------+---------------------+

| id | name | datetime |

+----+-------+---------------------+

| 1 | Hello | 2011-04-22 21:18:00 |

+----+-------+---------------------+

1 row in set (0.02 sec)

Mysql存储过程的插入语句怎么写?

CREATE DEFINER = CURRENT_USER PROCEDURE `NewProc`(IN `username` varchar,IN `passwords` varchar)

BEGIN

INSERT INTO test_user (Username,Passwords) VALUES (username, passwords);

END;

php 调用mysql存储过程 输入多个参数,出参只需一个如何写?

以下只是个例子

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 * --------这部分请将传入的参数带入查询的条件中

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

mysql 语句 怎样传递一个函数的参数

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 :此函数是将一个中文字符串对应拼音母的每个相连 (例如:"中国人"-ZGR)

复制代码 代码如下:

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

示例:

复制代码 代码如下:

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 | NMGZZQ |

+------------------+-------------------------+--------------------+

5 rows in set


当前文章:mysql语句入参怎么写,mysql删除语句怎么写
标题链接:http://jkwzsj.com/article/hojepo.html

其他资讯