SQL
1、建库建表删表:
建库:
create database if not exists (库名)defaule charset utf8;
表名:
create table if not exists 表名(
字段名 int primary key auto_increment,
字段名 varchar(20) not null,
字段名 varchar(20) not null,
字段名 date not null
);
删表:
drop table (表名);
2、字段类型:
int类型:用于大整数值。
float类型:用于单精度,浮点数。
double类型:用于双精度,浮点数、
3、字符串类型
char:用于定长字符。
varchar:用于定长字符串。
text:用于长文本。
查询语句
select * from (表名);
增加语句
insert into (表名)
insert into (表名)(表字段名)VALUES
(表数据),
(表数据),
(表数据);
删除语句
delete from (表名)where (表字段)=3
表关联查询
内连接 inner join
select * from A inner join B on A.id = B.id
左连接 left join
select * from A left join B on A.id = B.id
右连接 right join
select * from A right join B on A.id = B.id
联合查询union
select 字段名 FROM (表名) UNION SELECT 字段名