select * from pet;
insert into pet values('Liujingwei','Liuchao','cat','f','1984-04-18',null);
UPDATE pet set birth='1989-08-31' WHERE name='Slim';
select * from pet WHERE birth>'1998-1-1';
SELECT * from pet WHEREselect * from pet;
insert into pet values('Liujingwei','Liuchao','cat','f','1984-04-18',null);
UPDATE pet set birth='1989-08-31' WHERE name='Slim';
select * from pet WHERE birth>'1998-1-1';
SELECT * from pet WHERE species='dog' and sex='f';
select * from pet WHERE species='snake' or species='cat';
SELECT * from pet WHERE (species='cat' and sex='m') or (species='dog' and sex='f');
SELECT name,birth from pet;
SELECT owner from pet;
SELECT distinct owner from pet;
SELECT name,species,birth from pet where species='dog' or species='cat';
=======================================================================
select name,birth from pet ORDER BY birth;
select name,birth from pet order by birth desc;
select name,species,birth from pet order by species,birth desc;
========================================================================
select name,birth,curdate(),(year(curdate())-year(birth))-(right(curdate(),5)<right(birth,5)) as age from pet order by name;
select name,birth,curdate(),(year(curdate())-year(birth))-(right(curdate(),5)<right(birth,5)) as age from pet order by age;
select name,birth,curdate(),(year(curdate())-year(birth))-(right(curdate(),5)<right(birth,5)) as age from pet WHERE death IS NOT NULL ORDER BY age;
select name,birth ,month(birth) from pet;
SELECT name, birth from pet WHERE MONTH(birth) = 5;
SELECT name, birth from pet WHERE MONTH(birth) = MONTH(DATE_ADD(CURDATE(),INTERVAL 1 MONTH));
SELECT name, birth from pet WHERE MONTH(birth) = MOD(MONTH(CURDATE()), 12) + 1;
select 1 is null,1 is not null;
select 0 is null, 0 is not null,'' is null,'' is not null;
SELECT * from pet WHERE name LIKE 'b%';
SELECT * from pet WHERE name LIKE '%fy';
SELECT * from pet WHERE name LIKE '%w%';
SELEC
在开发不论是WEB还是Winform程序中,数据分页是经常遇到的问题,要是在代码中实现此过程,显然降低了服务器的效率,可以使用以下存储过程来实现。
CREATE PROCEDURE pagination
@tblName varchar(255), -- 表名
@strGetFields varchar(1000) = '*', -- 需要返回的列
@fldName varchar(255)= ......