Home  >  Article  >  Database  >  How to use Mysql using

How to use Mysql using

王林
王林forward
2023-06-03 20:43:091116browse

Example

In normal times, when we do related table queries, it usually looks like this

select * from 表1 inner join 表2 on 表1.相同的列=表2.相同的列;

Then it can be changed to this and it will have the same effect

select 表1的列 from 表1 inner join 表2 on 表1.相同的列=表2 .相同的列

Then it’s okay Change it to this

select * from 表1 inner join 表2 using(相同的列);

First type

SELECT * FROM type,article where type.id=article.type_id;

How to use Mysql using

How to use Mysql using

How to use Mysql using

##Second type

SELECT * FROM type inner join article on type.id=article.type_id;

How to use Mysql using

Third type

SELECT type.*,article.* FROM type inner join article USING(id);

How to use Mysql using##Table

CREATE TABLE `type` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '类型编号',
  `type_name` varchar(255) DEFAULT '' COMMENT '文章类型名称',
  `order_num` int(11) NOT NULL DEFAULT '0',
  `icon` varchar(255) DEFAULT '' COMMENT '自定义图标',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='文章类型表';

INSERT INTO `demo`.`type` (`id`, `type_name`, `order_num`, `icon`) VALUES ('1', '前端教程', '1', 'iconclass-9');
INSERT INTO `demo`.`type` (`id`, `type_name`, `order_num`, `icon`) VALUES ('2', '前端工具', '2', 'icontoolset');
INSERT INTO `demo`.`type` (`id`, `type_name`, `order_num`, `icon`) VALUES ('3', '随笔', '9', 'iconnote');
CREATE TABLE `article` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type_id` int(11) DEFAULT '0' COMMENT '文章类型编号',
  `title` varchar(255) DEFAULT '' COMMENT '文章标题',
  `article_content` text COMMENT '文章主体内容',
  `introduce` text COMMENT '文章简介',
  `add_time` int(11) DEFAULT NULL COMMENT '文章发布时间',
  `view_count` int(11) DEFAULT '0' COMMENT '浏览次数',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='文章内容表';

INSERT INTO `demo`.`article` (`id`, `type_id`, `title`, `article_content`, `introduce`, `add_time`, `view_count`) VALUES ('1', '1', 'Vue3.x 的生命周期和钩子函数', '# 简要描述\r\n\r\n- 用户注册接口\r\n\r\n 请求URL\r\n- ` http://xx.com/api/user/register `\r\n  \r\n 请求方式\r\n- POST \r\n\r\n 参数\r\n\r\n|参数名|必选|类型|说明|\r\n|:----    |:---|:----- |-----   |\r\n|username |是  |string |用户名   |\r\n|password |是  |string | 密码    |\r\n|name     |否  |string | 昵称    |\r\n\r\n# 返回示例 \r\n\r\n```\r\n  {\r\n    \"error_code\": 0,\r\n    \"data\": {\r\n      \"uid\": \"1\",\r\n      \"username\": \"12154545\",\r\n      \"name\": \"吴系挂\",\r\n      \"groupid\": 2 ,\r\n      \"reg_time\": \"1436864169\",\r\n      \"last_login_time\": \"0\",\r\n    }\r\n  }\r\n```\r\n\r\n返回参数说明 \r\n\r\n|参数名|类型|说明|\r\n|:-----  |:-----|-----                           |\r\n|groupid |int   |用户组id,1:超级管理员;2:普通用户  |\r\n\r\n# 备注 \r\n\r\n- 更多返回错误代码请看首页的错误代码描述', 'Vue3.x 生命周期', '1640069422', '2');
INSERT INTO `demo`.`article` (`id`, `type_id`, `title`, `article_content`, `introduce`, `add_time`, `view_count`) VALUES ('3', '3', 'Redis + NodeJS 实现一个能处理海量数据的异步任务队列系统', '在最近的业务中,接到了一个需要处理约十万条数据的需求。这些数据都以字符串的形式给到,并且处理它们的步骤是异步且耗时的(平均处理一条数据需要 25s 的时间)。如果以串行的方式实现,其耗时是相当长的:', '异步任务队列系统', '1640069422', '15');

The above is the detailed content of How to use Mysql using. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete