当前位置:Gxlcms > 数据库问题 > sql的基本语法

sql的基本语法

时间:2021-07-01 10:21:17 帮助过:3人阅读

database TestSqlSugar;

3.进入数据库

use TestSqlSugar;

4.删除数据库

drop database test;

二. 数据表

1.新建表 

(1) user

create table if not exists user(
    id int auto_increment,
    userName varchar(100) not null,
    userPassword varchar(500) not null,
    age int not null,
    regTime datetime default current_timestamp,
    departmentId int,
    primary key(id)
);

(2) department

create table if not exists department
(
    id int auto_increment,
    name varchar(100) not null,
    admin varchar(100) not null,
    phone varchar(15) not null,
    primary key(id)
);

2.表查询

select * from user
select * from department
### 包含条件查询
select * from user where id in (1);
### 分页limit temp1,temp2  调过temp1条temp2条数据
select * from user limit 1,2
### 双表左关联查询,表的重命名
select user.id as Id, user.departmentId as depId, user.userName as name from user user left join department dep on(user.departmentId = dep.id)

 

sql的基本语法

标签:rem   create   分页   select   code   rom   use   sql   arch   

人气教程排行