编辑代码

CREATE DATABASE test;
use test;
CREATE TABLE student (
	id int,
	name varchar(255),
	address varchar(255),
	city varchar(255)
);

INSERT INTO student VALUES (1, '张三', '李四家隔壁', '杭州');
INSERT INTO student VALUES (1, '李四',  '张三家隔壁', '北京');

SELECT * FROM student;
 select concat('共青团员');
 +--------------------+
 | concat('共青团员') |
 +--------------------+
 | 共青团员           |
 +--------------------+
 1 row in set (0.00 sec)
  select instr('该生政治面貌为','共青团员');
  +------------------------------------+
  | instr('该生政治面貌为','共青团员') |
  +------------------------------------+
  |                                  0 |
  +------------------------------------+
  1 row in set (0.00 sec)
   select left('该生政治面貌为',3);
   +--------------------------+
   | left('该生政治面貌为',3) |
   +--------------------------+
   | 该生政                   |
   +--------------------------+
   1 row in set (0.00 sec)
   select length('共青团员');
   +--------------------+
   | length('共青团员') |
   +--------------------+
   |                  8 |
   +--------------------+
   1 row in set (0.00 sec)
    select length('该生政治面貌为');
    +--------------------------+
    | length('该生政治面貌为') |
    +--------------------------+
    |                       14 |
    +--------------------------+
    1 row in set (0.00 sec)
     delimiter $$
      select concat('共青团员');
      +--------------------+
      | concat('共青团员') |
      +--------------------+
      | 共青团员           |
      +--------------------+
      1 row in set (0.00 sec)
       select instr('该生政治面貌为','共青团员');
       +------------------------------------+
       | instr('该生政治面貌为','共青团员') |
       +------------------------------------+
       |                                  0 |
       +------------------------------------+
       1 row in set (0.00 sec)
        select left('该生政治面貌为',3);
        +--------------------------+
        | left('该生政治面貌为',3) |
        +--------------------------+
        | 该生政                   |
        +--------------------------+
        1 row in set (0.00 sec)
        select length('共青团员');
        +--------------------+
        | length('共青团员') |
        +--------------------+
        |                  8 |
        +--------------------+
        1 row in set (0.00 sec)
         select length('该生政治面貌为');
         +--------------------------+
         | length('该生政治面貌为') |
         +--------------------------+
         |                       14 |
         +--------------------------+
         1 row in set (0.00 sec)
          delimiter $$
           create function f2 (i int)
             returns int
                  begin
                       declare i int;
                            if i%2 = 偶数 then
                                 return 偶数;
                                      else
                                           return 奇数;
                                                end if;
                                                     end $$
                                                     delimiter %%
                                                      create function scorel(i int)
                                                         returns char(6)
                                                             begin
                                                                declare j int;
                                                                     declare cj char(6);
                                                                          case
                                                                              when j>=90 then set cj='A级';
                                                                                when j>=80 and j<90 then set cj='B级';
                                                                                   when j>=70 and j<80 then set cj='C级';
                                                                                       when j>=60 and J<70 then set cj='D级';
                                                                                           else set cj='E级';
                                                                                               end case;
                                                                                                 return cj;
                                                                                                    end %%
                                                                                                    delimiter &&
                                                                                                    create function F3(i int)
                                                                                                        returns int
                                                                                                            begin
                                                                                                                 declare i int
                                                                                                                     ;
                                                                                                                         if i%3=0 then
                                                                                                                             return 整除;
                                                                                                                                 else
                                                                                                                                    return 没有被整除;
                                                                                                                                       end if;
                                                                                                                                           end &&