码迷,mamicode.com
首页 > 数据库 > 详细

SQL的学习

时间:2014-11-15 11:29:20      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:database   sql   

create database hpf;
use hpf;
create table hdfdf (
id int(10) NOT null auto_increment,
uid varchar(10) not null default 0,
remark text null,
primary key (id)
)
show tables;
select * from hdfdf;
select id as idenfiy from hdfdf;
select * from test where id!=1;
select * from test where id<>1;
select * from test where id in (1,2);
select * from test where id not in (1,2);
select * from test where id between 1 and 3;
select * from test where id not between 1 and 3;
select * from test where id=1 and remark="学生";
select * from test group by remark;
select * from test order by regdate (asc\desc);
select * from test limit 0,3;
select * from test ;
select count(*) as num from test;
select max(id) as num from test;
select min(id) from test;
select avg(id) from test;
select sum(id) from test;
select * from test where uid like '%王%';
alter table hdfdf drop remark;
alter table hdfdf add remark text null after id;
alter table hdfdf add name varchar(20) null;
insert into test (uid,regdate,remark) values (5,now(),'老师');
update test set uid='万网' where id=5;
delete from test where id=6






create table message(
id tinyint(1) not null auto_increment,
user varchar(25) not null,
title varchar(50) not null,
content tinytext not null,
lastdate date not null,
primary key (id)
)engine=InnoDB default charset=gbk auto_increment=1;






select * from message;

SQL的学习

标签:database   sql   

原文地址:http://blog.csdn.net/dapeng0112/article/details/41143859

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!