--if/else语句 if 条件 then SQL语句 else SQL语句elseifSQL语句 end if; create procedure test1( number int ) begin then select user(); else select 'please input a number > 10'; end if; end$ mysql> create procedure test1( -> number int -> ) -> begin then…
#用在储存过程中: create procedure k() begin declare number int; )); case number then select '>0'; else select '=0'; end case; end$ #用在查询中: select case user when 'root' then 'yes' else 'no' end from mysql.user;select case when user='root' then 'yes' else 'no…
循环结构 while create procedure name() begin while 条件 do SQL语句 end while; end$ create procedure aa6() begin ; do select number; ; end while; end$ mysql> create procedure aa6() -> begin -> declare number int default 0; -> w…
储存过程 DELIMITER // CREATE PROCEDURE pro1() BEGIN SELECT book_id,book_name,category FROM bookinfo t1 JOIN bookcategory t2 ON t1.book_category_id = t2.category_id; END// DELIMITER ; DELIMITER // ),OUT num INT) BEGIN DELETE FROM reader_info WHERE card_id…
现在mysql上定义一个函数,一个储存过程 函数: delimiter \\ CREATE FUNCTION f2 ( num2 INT, num1 INT ) RETURNS INT BEGIN DECLARE a DEFAULT INT 1; SET a = num1 * num2; RETURN ( a ) ; END \\ delimiter; 函数式是计算两个值相乘的 在mysql的调用 select f2(9,5); -- 45 同时函数可以是配合select 函数 from 来使用…
--一句Sql把表结构全部查询出来 SELECT 表名 = Case When A.colorder=1 Then D.name Else '' End, 表说明 = Case When A.colorder=1 Then isnull(F.value,'') Else '' End, 字段序号 = A.colorder, 字段名 = A.name, 字段说明 = isnull(G.[value],''), 标识 = Case When COLUMNPROPERTY( A.id,A.name,'…
存储过程 create or replace procedure TestPro(Descerr out varchar2 ) is begin select * from test; exception when others then Descerr :='接口表数据生成失败!'|| sqlerrm; end TestPro; job任务 ); begin--储存过程 TestPro(Descerr=>descerr); commit; end 视图 create or replace vi…
VS2013, MySQL5.7.18 , MySQL5.7.14 执行SQL语句: ztp_user z = new ztp_user(); object[] obj = new object[] { z }; MySqlParameter[] p = new MySqlParameter[]{ new MySqlParameter("@username","admin1") }; var result = db.Database.SqlQuery<ztp_…