Navicat Premium mysql

#Sql语句  创建一表格
create table user3(id int(11),name varchar(32),age int (3),sex char(1));

#添加语句
insert into user3(id ,name,age,sex)values(1,'张三',99,'');
insert into user3 values(4,'王五',21,'');
#删除
delete from user3;#user3中所有数据全删
delete from user3 where name='张三';
delete from user3 where name='张三' and age=99;#and 出现在条件与条件之间
delete from user3 where name='张三' & age=99;#???为何没效果 &最好不用,Java中转义字符
#修改
update user3 set sex='' where name='李四' and age=22;
update user3 set sex='',age=2 where name='李四' and age=22;#同时改多个
#查询
select name,id,age,sex from user3;#查询所有
select * from user3;#查询所有 顺序
select name from user3;#查询所有姓名
select id,name,age,sex from user3 where name='李四' and age=2;
select id,name,age,sex from user3 where name='李四' or age=2;

select * from user3 order by id asc;#按id 升序排列
select * from user3 order by id desc;#按id 降序排列

 

posted @ 2016-07-22 20:48  kimsimple  阅读(325)  评论(0编辑  收藏  举报