MySql常用操作SQL语句汇总
作者:junjie 时间:2024-01-21 00:11:53
MySQL的常见操作在这里先做一下总结,已经整合到代码里面,经过检验无误。
/*创建一个数据库*/
create database xuning_test;
/*说明当时使用数据库对象*/
use xuning_test;
/*向数据库中添加表并且定义表的结构*/
create table person(
id int not null,
name varchar(16) not null,
sex varchar(16) not null,
age int not null,
address varchar(128) not null,
remark varchar(512) not null
);
/*向数据库的表中插入数据*/
insert into person value
(1,'name_1','men',99,'beijing','This is a frindsheep boy'),
(2,'name_2','men',88,'shanghai','ok great'),
(1,'name_3','man',77,'guangzhou','This is lickly'),
(1,'name_4','men',66,'beijing','This is a frindsheep boy'),
(1,'name_5','men',55,'beijing','you dont going to shool'),
(1,'name_6','man',44,'beijing','This is a frindsheep boy'),
(1,'name_7','men',33,'beijing','This is a frindsheep boy'),
(1,'name_8','man',22,'beijing',''),
(1,'name_9','men',11,'beijing','This is a frindsheep boy')
;
/*查询时否成功插入*/
select * from person;
/*下面是多种查询方式*/
/*根据列的名称属性值*/
select name from person;
/*添加条件-根据性别*/
select name from person where sex = 'men';
/*也可以用比较符作为条件--一定逗号隔开*/
select name,address from person where age > 50;
/*看做对象去使用数据库和表的关系=---双表关联--对象关系一定要明确*/
select xuning_test.person.name, xuning_test.person.id, xuning_test.person.age, xuning_test.person.address
from xuning_test.person, test1.test_xuning
where xuning_test.person.id = test1.test_xuning.id
;
/*使用表的别名进行查询*/
use xuning_test;
select c.name,sex from person as c where c.age > 40 and c.address='beijing';
标签:MySql,常用操作,SQL语句
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
基于python全局设置id 自动化测试元素定位过程解析
2022-04-28 18:52:08
用好Frontpage中的各种回车
2008-02-21 14:33:00
Pycharm内置终端及远程SSH工具的使用教程图文详解
2023-03-26 09:58:30
![](https://img.aspxhome.com/file/2023/6/101726_0s.png)
使用Javascript面向对象的思想编写ASP
2008-06-16 12:20:00
基于Python编写一个简单的服务注册发现服务器
2022-06-11 20:23:31
![](https://img.aspxhome.com/file/2023/4/65464_0s.png)
Pytorch自定义Dataset和DataLoader去除不存在和空数据的操作
2022-05-06 14:26:39
Python OpenCV学习之图像形态学
2022-01-16 21:48:29
![](https://img.aspxhome.com/file/2023/6/93746_0s.jpg)
初学JavaScript第二章
2024-04-17 10:11:30
zabbix监控Nginx/Tomcat/MySQL的详细教程
2024-01-15 04:31:33
![](https://img.aspxhome.com/file/2023/3/93893_0s.png)
Python实现批量修改文件名实例
2023-12-29 09:58:18
mssql server 数据库附加不上解决办法分享
2011-09-30 11:55:20
在Sublime Editor中配置Python环境的详细教程
2023-08-14 08:33:26
![](https://img.aspxhome.com/file/2023/8/97648_0s.png)
ajax中get和post的说明及使用与区别
2024-04-29 13:58:17
python实现k均值算法示例(k均值聚类算法)
2021-04-24 20:27:39
python爬虫库scrapy简单使用实例详解
2022-03-22 23:46:11
python Timer 类使用介绍
2022-09-02 18:36:37
tensorflow基于CNN实战mnist手写识别(小白必看)
2021-01-26 22:33:42
![](https://img.aspxhome.com/file/2023/2/99432_0s.png)
python中virtualenvwrapper安装与使用
2022-07-28 03:21:52
Access2000迁移到Oracle9i要点
2010-07-27 13:10:00
MySQL分区表实现按月份归类
2024-01-17 12:56:36